di-container
Basic Dependency Injection (DI) container for Node.js inspired by code examples found in the book Node.js Design Patterns.
Installation
$ npm install di-container
Usage
Factory functions can simply list their dependencies in the argument list (as made popular by AngularJS). Alternatively a module can be defined as an array of dependency names followed by the factory function. The latter form is more resilient to code minifcation and name mangling.
Example
/* lib/person-factory.js */module { return name: name ;} /* lib/animal-factory.js */moduleexports = 'type' { return type: a ;} /* index.js */var DiContainer = ;var diContainer = ; diContainer;diContainer; var person = diContainer;// person.name == 'alice' diContainer;diContainer; var animal = diContainer;// animal.type == 'dog'