inject-params
v0.0.3
Published
Dynamic argument injection using function parameters
Downloads
1
Maintainers
Readme
Dynamic argument injection using function parameters.
Install
npm install inject-params
Usage
Arguments are dynamically injected into a function based on the parameters it expects.
Arguments can be retrieved from an object using its keys.
var injectParams = require("inject-params");
var allOptions = {
firstName: "John",
lastName: "Doe",
callNow: function () {
// ...
}
};
function callJohn(callNow, lastName) {
// ...
}
injectParams(callJohn, allOptions);
Arguments can also be retrieved using a lookup function.
var injectParams = require("inject-params");
function lookupParams(key) {
// ...
return someVal;
}
function contactSomePerson(details, emailNow) {
// ...
}
injectParams(contactSomePerson, lookupParams);
Sources
- http://stackoverflow.com/questions/15270311/angularjs-how-does-the-di-system-know-of-the-name-of-the-arguments
- http://jsfiddle.net/arunpjohny/p6qQT/1/