Never-ending Pumpkin Mulch

    currymember

    0.9.0 • Public • Published

    Currymember

    Just like all the other curry modules except it modifies Function.prototype.

    Adds a member function to Functions allowing currying in Javascript. Useful for passing state to event handlers.

    Implementation

    Function.prototype.curry = function() {
      var args = Array.prototype.slice.call(arguments), self = this;
      return function() {
        return self.apply(
          self, 
          args.concat(Array.prototype.slice.call(arguments))
        );
      }
    }

    Example:

    var add = function (a, b) { 
      return a+b; 
    };
    var add_one = add.curry(1);
    add_one(1).should.equal(2);
    add_one(2).should.equal(3);

    Keywords

    none

    Install

    npm i currymember

    DownloadsWeekly Downloads

    0

    Version

    0.9.0

    License

    none

    Last publish

    Collaborators

    • sbquinlan