Skip to content

Instantly share code, notes, and snippets.

@bga
Created December 12, 2010 20:10
Show Gist options
  • Save bga/738296 to your computer and use it in GitHub Desktop.
Save bga/738296 to your computer and use it in GitHub Desktop.
/*
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