dein

4.0.1 • Public • Published

dein - dependency injection framework

A small dependency injection framework for node.js.

  • Register modules with dependencies.
  • Register literals without dependencies.
  • Dependency injection framework is immutable.

Features

  • dein is lazy. Only dependencies which are used are resolved
  • dein allows async dependency resolution by using promises. You can mix synchronous factory methods with asynchronous ones.
  • dein will automatically find the required dependency. No need to define the order of dependencies.

Quick Start

npm install dein
const dein = require('dein');

Examples

dein
  .registerLiteral('someString', 'Hello World')
  .register('someModule', someString => `${someString}!!!`)
  .resolve('someModule')
  .then((result) => {
    console.log('Result: ' + result);
    // Expected: `Result: Hello World!!!
  });

Tests

npm test

Readme

Keywords

none

Package Sidebar

Install

npm i dein

Weekly Downloads

3

Version

4.0.1

License

MIT

Unpacked Size

12.5 kB

Total Files

7

Last publish

Collaborators

  • mren