-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmoduller.js
More file actions
33 lines (33 loc) · 1.11 KB
/
Copy pathmoduller.js
File metadata and controls
33 lines (33 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
(function(define) {
return define(function() {
return function() {
return {
module: function(path, cb) {
var dest = this;
var chunks = path.split('.');
if (chunks[0] === 'module') {
console.error('You have no ability to set path like `module`!');
return false;
}
chunks.forEach(function(chunk) {
if (!dest[chunk]) {
dest[chunk] = {};
}
dest = dest[chunk];
});
if (cb && typeof cb === 'function') {
cb(dest);
}
}
};
};
});
})(typeof define !== 'undefined' ? define : function(factory) {
if (typeof module !== 'undefined' && typeof exports !== 'undefined') {
module.exports = factory();
return module.exports;
} else {
window.Moduller = factory();
return window.Moduller;
}
});