Created
July 17, 2011 00:48
-
-
Save liammclennan/1086987 to your computer and use it in GitHub Desktop.
Example JavaScript Module that supports dependency injection
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
| // Module A.js | |
| exports = function(dep1, dep2) { | |
| dep1 = dep1 || require('dep1'); | |
| dep2 = dep2 || require('dep2'); | |
| return { | |
| action: function() { | |
| return dep1.foo() + dep2.bar(); | |
| } | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment