inject-params

    0.0.3 • Public • Published

    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

    Install

    npm i inject-params

    DownloadsWeekly Downloads

    5

    Version

    0.0.3

    License

    MIT

    Last publish

    Collaborators

    • merrihew