toloframework
Version:
Javascript/HTML/CSS compiler for Firefox OS or nodewebkit apps using modules in the nodejs style.
24 lines (22 loc) • 664 B
JavaScript
var require = function() {
var modules = {};
return function(id, body) {
var mod;
body = window["#" + id];
if (typeof body === 'undefined') {
var err = new Error("Required module is missing: " + id);
console.error(err.stack);
throw err;
}
mod = modules[id];
if (typeof mod === 'undefined') {
mod = {exports: {}};
var exports = mod.exports;
body(exports, mod);
modules[id] = mod.exports;
mod = mod.exports;
//console.log("Module initialized: " + id);
}
return mod;
};
}();