1 | var root = typeof window !== 'undefined' && window !== null ? window : global;
|
2 | root.$IMA = root.$IMA || {};
|
3 | root.$IMA.Test = true;
|
4 | root.$IMA.$Debug = true;
|
5 | root.$Debug = true;
|
6 |
|
7 | root.$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 |
|
19 | root.extend = extend;
|
20 | root.using = using;
|
21 | root.$import = $import;
|
22 |
|
23 | function 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 |
|
32 | function extend(ChildClass, ParentClass) {
|
33 | ChildClass.prototype = new ParentClass();
|
34 | ChildClass.prototype.constructor = ChildClass;
|
35 | }
|
36 |
|
37 | function $import(path, name) {
|
38 | var module = $IMA.Loader.importSync(path);
|
39 | name = name || 'default';
|
40 |
|
41 | return name === '*' ? module : module[name];
|
42 | }
|