New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

iniettore

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iniettore

A light and simple IoC container

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
decreased by-81.63%
Maintainers
1
Weekly downloads
 
Created
Source

Iniettore Iniettore

Build Status GitHub version NPM dependencies Coverage Status

TODO

  • Make singletons dispose method name configurable
  • Improve instanciate function to copy static methods/properties to the Surrogate constructor

Features

Specify ECMA Script 5 required features or polyfills

  • Object.create
  • Function.prototype.bind

Quick start

Installation

node.js:

npm install iniettore --save

Simple usage

import iniettore from 'iniettore'
import { VALUE, SINGLETON, CONSTRUCTOR } from 'iniettore/lib/options'

class UltimateQuestion {
	constructor(answer) {
		console.log(answer)
	}
}

var container = iniettore.create(function (context) {
	context
		.map('answer')
		.to(42)
		.as(VALUE)

		.map('question')
		.to(UltimateQuestion)
		.as(SINGLETON, CONSTRUCTOR)
		.injecting('answer')
})

var question = container.get('question') // 42

console.log(question instanceof UltimateQuestion) // true

Advanced usage

Value objects and instances

import iniettore from 'iniettore'
import { VALUE, INSTANCE } from 'iniettore/lib/options'

var drone = {
	fly: function () { /*...*/ }
}

var container = iniettore.create(function (context) {
	context
		.map('answer')
		.to(42)
		.as(VALUE)

		.map('drone')
		.to(drone)
		.as(INSTANCE)
})

var answer = container.get('answer')

console.log(container.get('drone') === drone) // true

Functions

Providers

Constructor

Child context

Blueprint

Transient dependencies

Notes on singletons

Notes on lifecycle

Instances dispose

Context dispose

Throubleshooting

Keywords

FAQs

Package last updated on 28 Jul 2014

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