Skip to content

Instantly share code, notes, and snippets.

@elarkin
Created December 31, 2010 05:03
Show Gist options
  • Save elarkin/760741 to your computer and use it in GitHub Desktop.
Save elarkin/760741 to your computer and use it in GitHub Desktop.
An example of how module.declare and require would be defined on the client side
window.module = (function() {
var module = {};
var modules = {};
module.require = function require(mod_name) {
return modules[mod_name];
};
module.declare = function declare(f) {
if(typeof f === 'function') {
var m = {};
modules[f.name] = f.call(module, module.require, m, module) || m;
} else {
// ??? what do I name the module ???
}
};
return module;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment