Created
October 14, 2011 13:12
-
-
Save jarek-foksa/1287050 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
var modules = {}; | |
var _require; | |
var require = _require = function(scriptName) { | |
if (modules[scriptName] === undefined) { | |
console.error("require('" + scriptName + "'): file not found."); | |
return; | |
} | |
if (modules[scriptName].cached) { | |
return modules[scriptName].cached; | |
} | |
else { | |
return modules[scriptName](); | |
} | |
} | |
function module(scriptName, scriptContent) { | |
modules[scriptName] = function() { | |
var exports = {}; | |
var require = function (scriptName) { | |
return _require(scriptName); | |
}; | |
modules[scriptName].cached = exports; | |
(function() { | |
scriptContent(exports); | |
}).call(exports); | |
return exports; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment