node package manager
Don’t reinvent the wheel. Reuse code within your team. Create a free org »



Similar to the standard curry function found in functional programming but allowing parameters to applied non-sequentially based on names matching a supplied object.

The primary purpose of this library is so you can use function parameters to include dependencies of that function and later normalize them into a standard form.

An Example

module.exports.register = function(err, req, res, bcrypt, emailSender, db, next) { }
module.exports.login = function(err, req, res, memcache, db, next) { }
var curryDi = require('curry-di');
var dependencies = {
	emailSender: var emailSender = curry(require('email-sender'))('localhost'),
	bcrypt: require('bcrypt'),
	db: db,
	memcacheApi: memcacheApi

// The return value of curryDi(dependencies, ...) is a function with the
// signature function(err, req, res, next) as all other parameters have 
// been matched to the dependences object.'/user/register', curryDi(dependencies, userRoute.register));'/user/login', curryDi(dependencies, userRoute.login));