Skip to content
Carlos De Dios edited this page Oct 20, 2015 · 1 revision

Description

Takes a function that receives n parameters and yields a function that will wait until n parameters are provided before invoking the original function.

Example

/* Regular Approach */

let divide = (a, b) => a / b;
// divide(10) => undefined; divide(10, 2) => 5

let divideBy = (b) => (a) => a / b;
// divideBy(10) => Function; divideBy(2)(10) => 5

let halve = divideBy(2);
return halve(10);

/* Curry Approach */

let divide = curry((b, a) => a / b);
// divide(10) => Function; divide(2, 10) => 5; divide(2)(10) => 5

let halve = divide(2);

return halve(10);

Clone this wiki locally