-
-
Save kriskowal/339654 to your computer and use it in GitHub Desktop.
This file contains 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
require.def({ | |
'increment': { | |
'requires': ['math'], | |
'factory': function() { | |
var exports = arguments[0].exports, | |
require = arguments[0].require, | |
module = arguments[0].module; | |
var add = require('math').add; | |
exports.increment = function(val) { | |
return add(val, 1); | |
}; | |
} | |
}, | |
'math': { | |
'requires': [], | |
'factory': function() { | |
var exports = arguments[0].exports, | |
require = arguments[0].require, | |
module = arguments[0].module; | |
var add = require('math').add; | |
exports.add = function() { | |
var sum = arguments[0]; | |
for (var i=1; i<arguments.length; i++) { | |
sum += arguments[i]; | |
} | |
return sum; | |
}; | |
} | |
} | |
}); | |
var eventualTwo = Q.when(require.async('increment'), function(mod) { | |
var inc = mod.increment; | |
var a = 1; | |
return inc(a) // 2 | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment