namespace('math', [], function(){
function add(a, b) { return a + b };
function sub(a, b) { return a - b };
return {
add,
sub
}
});
namespace('calculator', ['math'], function(m){
var action = 'add';
function compute(a, b){
m[action](a, b);
}
return {
compute
}
});
var namespace = (function () {
var cache = {};
return function createModule(name, deps, fn) {
deps = deps.map(function (depsName) {
return cache[depsName];
});
cache[name] = fn.apply(null, deps);
return cache[name];
};
})();