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

async-didi

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-didi

Async Dependency Injection for JavaScript

  • 0.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
27
decreased by-6.9%
Maintainers
1
Weekly downloads
 
Created
Source

async-didi

Build Status

An async version of didi, the tiny dependency injection container for JavaScript.

Example

import {
  AsyncInjector
} from 'async-didi';

function Car(engine) {
  this.start = function() {
    engine.start();
  };
}

async function createEngine(power) {
  return {
    start: function() {
      console.log('Starting engine with ' + power + 'hp');
    }
  };
}

const injector = new AsyncInjector([
  {
    'car': ['type', Car],
    'engine': ['factory', createEngine],
    'power': ['value', 1184]
  }
]);

await injector.invoke(async function(car) {
  await car.start();
});

For more examples, check out the tests.

Comparison to didi

  • Same core features
  • Exposes an AsyncInjector
  • Injector API functions get, invoke and instantiate are async
  • Factory functions may be async
  • No support for child injectors and scopes

License

MIT

Keywords

FAQs

Package last updated on 04 Nov 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

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