0.1.9 • Published 11 years ago
injekt v0.1.9
INJEKT is a tiny, integration-tested dependency injection framework for NodeJS.
- Background Philosophy
- Installation
- Library Instantiation
- Module Injection
- Current Goals
- Future Thoughts
- Bug Reports + Other Requests
- Further Notes
Feel free to skip ahead if you know what you're looking for.
Background Philosophy
NOTE: This section is still under construction.
Installation Options
In addition to the options below, you can download either the raw export or package tarball.
Install via npm
:
npm install injekt
Clone GIT repository:
git clone git@github.com:arkbot/injekt.git
Syntax: Library Instantiation
General Usage:
require('injekt')(
default_options
[, closure]
);
The following examples are all valid. Use them wisely.
Minimal Reference
var injekt = require('injekt')();
- NOTE:
closure
defaults to empty{ }
whendefault_options
are excluded.
Reference via require(...)
: injekt(...)
var injekt = require('injekt')({
'context' : {
'inspect' : require('util').inspect
},
'mocks' : {
'assert' : require('should')
}
}, { });
Reference via closure
: closure.injekt(...)
var closure = {};
require('injekt')({
'context' : {
'inspect' : require('util').inspect
},
'mocks' : {
'assert' : require('should')
}
}, closure);
Reference via global
: global.injekt(...)
require('injekt')({
'context' : {
'inspect' : require('util').inspect
},
'mocks' : {
'assert' : require('should')
}
});
- NOTE:
closure
defaults toglobal
when excluded.
Syntax: Module Injection
General Usage:
injekt(
module_path
[, options]
);
INJEKT gives you two different methods of injecting your dependencies:
context
: embed directly into theglobal
context of your product module.mock
: available as a mock to be retrieved viarequire(...)
inside your product module.
var my_module = injekt('./my_module.js', {
'context' : {
'EventEmitter' : require('events').EventEmitter
},
'mocks' : {
'Foo' : Object.create({ bar: function () { return 'YIPPPEEEE!'; } })
}
});
- NOTE:
module_path
must be relative to the overall working directory.
Current Goals
- Set up milestones on GitHub's Issue Tracker
- Create proper API + usage documentation
Future Thoughts
- Use factories for
params
parsing /properties
building - Integrate browser compatability:
- Setup individual interfaces for RequireJS and NodeJS.
- Investigate engine support for Contextify.
Bug Reports + Other Requests
Please submit an issue on the GitHub Issue Tracker.
Please attach at least one of the following for bug reports:
- diagnostic procedure
- sample code
- assertion tests
Please e-mail me before sending a pull request.
Further Notes
- Released under the MIT License (attached).
- Accompanied by a full integration test suite, via
should
andvows
.