Skip to content

eborden/js-curry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 

Repository files navigation

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]

curried = curry(function (a, b, c) {
	return a + b + c;
});
curried(1)(2)(3); //6

curriedOne = $curried(1);
curriedOne(2)(3); //6

Reverse Currying is also possible

//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-curry

Benchmark

http://jsperf.com/js-curry-bench/3

About

Real curry behavior in JavaScript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published