Created
December 12, 2010 20:10
-
-
Save bga/738296 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
unfortunately you can not debug it :( | |
*/ | |
(function($G) | |
{ | |
$G._import = function(_fn, modules) | |
{ | |
var argsString = ''; | |
var args = []; | |
var i = modules.length; while(i--) | |
{ | |
var module = modules[i]; | |
for(var j in module) | |
{ | |
if(module.hasOwnProperty(j)) | |
{ | |
argsString += j + ','; | |
args.push(module[j]); | |
} | |
} | |
} | |
argsString += '$G'; | |
args.push($G); | |
var code = String(_fn); | |
Function(argsString, code.slice(code.indexOf('{') + 1, code.lastIndexOf('}'))).apply($G, args); | |
}; | |
})(this); | |
(function($G) | |
{ | |
var export = $G.$A = {}; | |
export.A = 'A'; | |
})(this); | |
(function($G) | |
{ | |
var export = $G.$B = {}; | |
export.B = 'B'; | |
})(this); | |
_import(function($G){ | |
console.log(A, B); | |
}, [$A, $B]); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment