-
-
Save gordonbrander/8811045 to your computer and use it in GitHub Desktop.
This file contains hidden or 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(exports) { | |
var modules = {} | |
var factories = {} | |
// Require a module by id. | |
function require(id) { | |
if (!(id in factories)) throw Error(id + ' module is not defined') | |
if (!(id in modules)) { | |
modules[id] = {} | |
factories[id](require, modules[id]) | |
} | |
return modules[id] | |
} | |
exports.require = require | |
require.modules = modules | |
require.factories = factories | |
// Define a module with id. | |
function define(id, factory) { | |
if (id in factories) throw new Error(id + ' module is already defined') | |
factories[id] = factory | |
} | |
exports.define = define | |
})(this) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment