You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 10, 2024. It is now read-only.
To get a registered dependency, simply use container.get:
constlogger=container.get('logger');// This will print "formatted logged message"console.log(logger);
API
container.factory(name, function) - Registers a factory dependency by name. function must be a function that takes dependencies and returns anything.
container.constant(name, object) - Registers a constant dependency by name. object must be an object or string with no dependencies.
container.get(name, overrides = {}) - Returns a dependency by name, with all dependencies injected. If you specify overrides, the dependency will be given those overrides instead of those registered.
container.getSandboxed(name, overrides = {}) - Returns a dependency by name, with all dependencies injected. Unlike get, you must specify overrides for all dependencies. This can (and should) be used during testing to ensure a module under test has been competely isolated.
Development
Tests are written with Mocha. To run the tests, run npm test.