UNPKG

1.03 kBJavaScriptView Raw
1var root = typeof window !== 'undefined' && window !== null ? window : global;
2root.$IMA = root.$IMA || {};
3root.$IMA.Test = true;
4root.$IMA.$Debug = true;
5root.$Debug = true;
6
7root.$IMA.Loader = root.$IMA.Loader || {
8 register: function() {},
9 replaceModule: function() {},
10 import: function() {
11 return Promise.resolve();
12 },
13 importSync: function() {},
14 initAllModules: function() {
15 return Promise.resolve();
16 }
17};
18
19root.extend = extend;
20root.using = using;
21root.$import = $import;
22
23function using(values, func) {
24 for (var i = 0, count = values.length; i < count; i++) {
25 if (Object.prototype.toString.call(values[i]) !== '[object Array]') {
26 values[i] = [values[i]];
27 }
28 func.apply(this, values[i]);
29 }
30}
31
32function extend(ChildClass, ParentClass) {
33 ChildClass.prototype = new ParentClass();
34 ChildClass.prototype.constructor = ChildClass;
35}
36
37function $import(path, name) {
38 var module = $IMA.Loader.importSync(path);
39 name = name || 'default';
40
41 return name === '*' ? module : module[name];
42}