5.1.0 • Published 3 years ago
@shepherdorg/nano-inject v5.1.0
Nano dependency injection.
Minimalistic dependency injection library.
The tests are the best documentation in this case.
import {expect} from 'chai'
import {inject} from './inject'
describe('inject dependency injection', function(){
it('should return injected dependency',function(){
var deps = inject({
foo:"bar"
});
expect(deps("foo")).to.equal('bar');
});
it('should fail on missing dependency',function(){
try{
var deps = inject({
foo:"bar"
});
deps("baz");
} catch (e){
expect(e.message).to.eql('Required dependency <baz> is not provided.');
}
});
it('should not fail on optional missing dependency', function(){
var deps = inject({
x:"bar"
});
expect(deps("foo", true)).to.equal(undefined);
})
});
5.1.0
3 years ago
5.0.0
4 years ago
4.3.0
4 years ago
4.0.0
4 years ago
3.0.0
4 years ago
2.2.0
4 years ago
2.0.2
4 years ago
2.0.1
4 years ago
2.0.0
4 years ago
0.0.7
5 years ago
0.0.6
5 years ago
0.0.5
5 years ago
0.0.4
5 years ago
0.0.3
5 years ago
0.0.2-alpha.1
5 years ago
0.0.2-alpha.0
5 years ago
0.0.1
5 years ago
1.0.0-rc.2
5 years ago
1.0.0-rc.1
5 years ago
1.0.0-rc.0
5 years ago
1.0.0-alpha.1
5 years ago