another-di
This is another dependency injector, because there aren't enough.
Usage
module.exports = function () {
return 'hello world!';
}
module.exports = function ({helloMessage}) {
return {
boom: function () {
console.log(helloMessage);
}
}
}
var di = require('another-di');
module.exports = di.create()
.singleton('helloMessage', require('./hello-message'))
.singleton('boomer', require('./boomer'))
var lib = require('./lib');
lib.run(function ({boomer}) {
boomer.boom();
});
var lib = require('./lib');
var boomer;
beforeEach(function () {
testContainer = lib.clone();
testContainer.singleton('helloMessage', function () {
return 'hello from test land';
});
testContainer.run(function ({_boomer}) {
boomer = _boomer;
})
})
it('should boom!', () => {
boomer.boom();
});