Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 27 lines (24 sloc) 0.636 kB
b8f5b92 @sbquinlan Tests and name change
authored
1 # Currymember
2 Just like all the other curry modules except it modifies Function.prototype.
3
4 Adds a member function to Functions allowing currying in Javascript. Useful for passing state to event handlers.
5
6 ## Implementation
7 ```javascript
8 Function.prototype.curry = function() {
9 var args = Array.prototype.slice.call(arguments), self = this;
10 return function() {
11 return self.apply(
12 self,
13 args.concat(Array.prototype.slice.call(arguments))
14 );
15 }
16 }
17 ```
18
19 ## Example:
20 ```javascript
21 var add = function (a, b) {
22 return a+b;
23 };
24 var add_one = add.curry(1);
25 add_one(1).should.equal(2);
26 add_one(2).should.equal(3);
27 ```
Something went wrong with that request. Please try again.