Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eborden/js-curry
Real curry behavior in JavaScript
https://github.com/eborden/js-curry
Last synced: 3 days ago
JSON representation
Real curry behavior in JavaScript
- Host: GitHub
- URL: https://github.com/eborden/js-curry
- Owner: eborden
- Created: 2013-05-26T20:08:20.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-05-29T01:21:15.000Z (over 11 years ago)
- Last Synced: 2024-11-03T18:34:48.015Z (10 days ago)
- Language: JavaScript
- Size: 226 KB
- Stars: 13
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
JavaScript Curry
========Many JavaScript curry functions are actually implementations of partial application. This module implements true curry behavior in JavaScript.
True curry behavior means only accepting a single argument at a time and only executing upon application of all arguments. [[citation](http://en.wikipedia.org/wiki/Currying)]
```JavaScript
curried = curry(function (a, b, c) {
return a + b + c;
});
curried(1)(2)(3); //6curriedOne = $curried(1);
curriedOne(2)(3); //6
```Reverse Currying is also possible
```Javascript
//verbose
curried = curry(function (a, b, c) {
return a + b + c;
}, true);//single argument convenience
curried = curry.r(function (a, b, c) {
return a + b + c;
});curried('a')('b')('c'); //'cba'
```Tests
--------Tests are written in jasmine. They can be run at http://tryjasmine.com/
To run from the command line:
npm install jasmine-node
jasmine-node path/to/js-curryBenchmark
----------http://jsperf.com/js-curry-bench/3