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

dependency-injector-container

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dependency-injector-container

Tiny library which does dependency injection. Basically same pattern like in AngularJS.

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

dependency-injector-container

Tiny library which does dependency injection. Basically same pattern like in AngularJS.

Getting Started

Install this plugin with this command:

npm install dependency-injector-container

API

API Documentation

Usage

Register all module defenitions to the dependency-injector-container and at the end call the load method to get everything loaded properly and in the right order.

Imagine you got several modules in different files which depend on each other. You'll somehow need to compile them in the right order otherwise those modules will throw exception. With this tiny library you don't need to care about that anymore. You just need to extend all your modules to the container and then at the end call .load(). Also there's the possibility to just call .get() after all modules are extended.

The pattern of this library is pretty similar to what's AngularJS is using.

This library will of course only be useful if you don't already use a compiler which already cares about internal script dependencies.

This library got the size of 1.6 KB.

Example

var DependencyInjectorContainer = require('dependency-injector-container');
var Application = new DependencyInjectorContainer();

//Testing
Application.extend('test',function(){
	return {
	  foo: 'bar'
	};
});

Application.extend('cow',['test','sheep'],function(test,sheep){
	console.log(test.foo, sheep);

	return {
	  lol: 'moo'
	};
});

Application.extend('sheep',['test'],function(test){
	console.log(test.foo);

	return {
	  legs: 'walk'
	};
});

Application.load();
var DependencyInjectorContainer = require('dependency-injector-container');
var Application = new DependencyInjectorContainer();

//Testing
Application.extend('test',function(){
	return {
	  foo: 'bar'
	};
});

Application.extend('cow',['test','sheep'],function(test,sheep){
	console.log(test.foo, sheep);

	return {
	  lol: 'moo'
	};
});

Application.extend('sheep',['test'],function(test){
	console.log(test.foo);

	return {
	  legs: 'walk'
	};
});

Application.get('cow');

Keywords

FAQs

Package last updated on 23 Jan 2016

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