Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

depin

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

depin

A simple dependency injection container.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

depin 📦

A simple dependency injection container.

npm version Build Status Coverage Status Known Vulnerabilities


Install

npm install --save depin

Quick start

const depin = require('depin');

const app = depin();

app.set('beatles', [
  { name: 'George' },
  { name: 'John' },
  { name: 'Paul' },
  { name: 'Ringo' },
]);

app.register('beatleService' (beatles) => ({
  getCount() {
    return beatles.length;
  },
}));

app.get('beatleService').count(); // 4

API

apply( factory:function ) :*

Run a function with all arguments injected from the DI container by name and return the result.

app.set({ one: 1, two: 2, three: 3 });
app.apply((one, two, three) => one + two + three); // 6
get( [name:string] ) :*

Get a value from the DI container.

app.set({ one: 1 });
app.get('one'); // value

When no name is passed app.get will return a dependency picker which is very useful when combined with object destructuring.

app.set({ one: 1, two: 2 });
const { one, two } = app.get();
register( factory:function ) :app

Register a factory.

app.set({ one: 1, two: 2 });
app.register(function myManager(one, two) {
  return { add: () => one + two };
});
app.get('myManager').add(); // 3

Or set its name directly.

app.set({ one: 1, two: 2 });
app.register('myManager', (one, two) => {
  return { add: () => one + two };
});
app.get('myManager').add(); // 3
run( func:function ) :app

Run a function with all arguments injected from the DI container by name.

app.set({ one: 1, two: 2 });
app.run((one, two) => {
  //
});
set( properties:object ) :app / set( name:string, value:* ):app

Set values in the DI container.

Keywords

FAQs

Package last updated on 09 Oct 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc