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

lightweight-di

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lightweight-di

Lightweight dependency injection for TypeScript and JavaScript

  • 0.8.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Lightweight Dependency Injection

npm version travis build status

A dependency injection library for node and the browser, based on Angulars DI. Optimized for use via TypeScript or babel decorators.

Getting started

1. Install the library in your project

npm install --save lightweight-di

2. Import the required decorators from the package

// TypeScript / Babel / Webpack
import { Injectable } from 'lightweight-di';

// Node.js / Browserify
const { Injectable } = require('lightweight-di');

3. Decorate classes with dependencies

@Injectable
class FileLogger {
    constructor(private fs: FileSystem) { }
    log(message: string) {
        fs.appendToFile('app.log', message);
    }
}

4. Bootstrap your application entry point with Injector

import { Injector } from 'lightweight-di';
const injector = Injector.resolveAndCreate([App, Dependency1, Dependency2]);
injector.get(App).run();

Documentation & Examples

For the full API check out the documentation or the examples on GitHub.

License

MIT

Keywords

FAQs

Package last updated on 23 Jun 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