Socket
Socket
Sign inDemoInstall

async-didi

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    async-didi

Async Dependency Injection for JavaScript


Version published
Weekly downloads
23
decreased by-64.62%
Maintainers
1
Install size
31.2 kB
Created
Weekly downloads
 

Changelog

Source

0.3.1

  • FIX: export CommonJS with js extension (again)

Readme

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

Last updated on 04 Nov 2021

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc