Created
March 13, 2010 17:27
-
-
Save Gozala/331447 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
function Global(){} | |
var G = Global.prototype = window || globalScope; | |
var global = new Global(); | |
function require(id) { | |
var preGlobals = Object.keys(global); | |
var exports = modules[id]; | |
factories[id].call(G, exports, require, metadata[id], global); | |
var Globals = Object.keys(global).forEach(function(key) { | |
if (0 > preGlobals.indexOf(key)) { // global introduced by module | |
if (!global.hasOwnProperty(key)) { | |
// was not introduced by commonjs module | |
// cause in that case it would've be global.foo = "bar"; | |
exports[key] = G[key]; // exporting | |
G[key] = undefined; // removing from global | |
} | |
} | |
}) | |
return exports; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment