Socket
Socket
Sign inDemoInstall

little-di

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    little-di

A very simple implementation of dependency injection concept for both frontend and backend in ES6.


Version published
Weekly downloads
2
Maintainers
1
Install size
27.6 kB
Created
Weekly downloads
 

Readme

Source

Little DI

A very simple implementation of dependency injection concept for both frontend and backend in ES6.

Usage

const classesConfig = [
    {
        clazz: Engine,
        scope: 'prototype'
    },
    {
        clazz: Car,
        dependencies: [Engine],
        scope: 'prototype'
    },
    {
        clazz: Manufacture
    }
];
const container = new Container(classesConfig);

container.getClass('Engine');

API

Container class

ConstructorDescription
Container(config:ClassesConfig)Creates an container for all registered classes instances management. One application should only have one container.
MethodsDescription
getClass()Return Value: Class<T> - Fetches the scoped instance of the class.

ClassesConfig object specification

PropertiesDescription
clazzType: Class<T> - The instances of which to be managed.
dependenciesType: [Class<T>, <...>] - An array of dependent classes.
scopeType: string - the scope of the class instance. Available scopes are: SCOPE_SINGLETON and SCOPE_PROTOTYPE. Defaults to SCOPE_SINGLETON.

Keywords

FAQs

Last updated on 05 Jun 2017

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