Skip to content

Instantly share code, notes, and snippets.

@liammclennan
Created July 17, 2011 00:48
Show Gist options
  • Select an option

  • Save liammclennan/1086987 to your computer and use it in GitHub Desktop.

Select an option

Save liammclennan/1086987 to your computer and use it in GitHub Desktop.
Example JavaScript Module that supports dependency injection
// 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