-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmodJS-sync.js
More file actions
46 lines (42 loc) · 1.22 KB
/
modJS-sync.js
File metadata and controls
46 lines (42 loc) · 1.22 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
34
35
36
37
38
39
40
41
42
43
44
45
46
var require, define;
(function(self) {
var modules = {};
require = function(name){
var mod = modules[name], msg;
if (!mod) {
msg = 'Requiring unknown module "' + name + '"';
throw new Error(msg);
}
if (mod.hasError){
throw new Error('Requiring module "' + name + '" which threw an exception');
}
if (!mod.defined) {//避免循环调用
var exp = mod.exports = {}, fac = mod.factory;
if (Object.prototype.toString.call(fac) === '[object Function]') {
var ret, args = [];
try {
mod.defined = true;
ret = fac.call(self, require, exp, mod);
} catch (err) {
mod.hasError = true;
throw err;
}
if (ret) mod.exports = ret;
} else{
mod.exports = fac;
}
}
return mod.exports;
}
define = function (name, factory) {
var mod = {
id: name,
factory: factory
}
modules[name] = mod;
};
define.amd = {
'jQuery': true,
'version' : '1.0.0'
};
})(this);