-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbo.js
More file actions
40 lines (39 loc) · 859 Bytes
/
bo.js
File metadata and controls
40 lines (39 loc) · 859 Bytes
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
(function(){
var _modules={},
scripts = document.getElementsByTagName('script'),
len = scripts.length,
currentScript = scripts[len-1];
function define(id,fn,update){
if(id==="")
return;
if(_modules[id]&&!update)
throw"Module "+id+" already exist!";
if(typeof fn === "function"){
_modules[id] = {id:id,fn:fn,exports:{}}
}else{
_modules[id]={exports:fn}}
}
window.bo = window.bo || {};
bo.require = function(id){
var mod=_modules[id],fn,ret;
if(mod){
fn=mod.fn;
if(fn){
ret=typeof fn==="function"?fn(bo.require,mod.exports,mod):fn;
if(ret)
mod.exports=ret;
delete mod.fn
}
return mod.exports
}else{
throw"Module "+id+" not exist!"
}
}
bo.module =function(){
if(arguments.length>=2){
return define.apply(define,arguments)
}else{
return require.apply(require,arguments)
}
}
})()