Created
December 31, 2010 05:03
-
-
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
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
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