@shepherdorg/nano-inject
TypeScript icon, indicating that this package has built-in type declarations

5.1.0 • Public • Published

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);
       })
   
   });
   
   

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
5.1.016latest
0.0.70YT6ea26df0bcb78bb369f4a35e350044184883e215
0.0.60YT6592234accc07a3c631e679417be15fc9a970179
0.0.50YT62c5c6c2b081ad042be55d2ffd2fe3c975642850
0.0.2-alpha.10canary

Version History

VersionDownloads (Last 7 Days)Published
5.1.016
5.0.00
4.3.00
4.0.00
3.0.00
2.2.01
2.0.20
2.0.10
2.0.00
0.0.70
0.0.60
0.0.50
0.0.40
0.0.2-alpha.10
0.0.2-alpha.00
1.0.0-rc.20
1.0.0-rc.10
1.0.0-rc.00
1.0.0-alpha.11

Package Sidebar

Install

npm i @shepherdorg/nano-inject

Weekly Downloads

18

Version

5.1.0

License

MIT

Unpacked Size

5.65 kB

Total Files

11

Last publish

Collaborators

  • stefaneg
  • nordfjord