Socket
Book a DemoInstallSign in
Socket

@shepherdorg/nano-inject

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shepherdorg/nano-inject

Minimalistic dependency injection library...

latest
Source
npmnpm
Version
5.1.0
Version published
Maintainers
2
Created
Source

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

Keywords

dependency injection

FAQs

Package last updated on 03 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts