Skip to content
/ di Public

Dependency Injection for node.js inspired by Angular.js

License

Notifications You must be signed in to change notification settings

sod/di

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sod-di

Dependency Injection for node.js

Install

npm install sod-di

Documentation

Example

var di = new require('sod-di')('MyDependencies');

di.register('pi').value(Math.PI);
di.register('logger').value(console);
di.register('area').factory(function(pi) {
	return function(radius) {
		return radius * radius * pi;
	};
});
di(function(logger, area) {
	logger.log(area(2)); // stdout: 12.566370614359172
});

Why

Using dependency injection instead of require() in your project hugely improves and simplifies the ability to write unit tests.

Features

  • create multiple independent dependency injectors
  • public / private dependencies
  • import dependency injectors to access its public dependencies
  • useful error handling
  • 100% unit test coverage

About

Dependency Injection for node.js inspired by Angular.js

Resources

License

Stars

Watchers

Forks

Packages

No packages published