Skip to content

Instantly share code, notes, and snippets.

@ashwell
Last active June 5, 2019 21:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashwell/53e2fe89204c74687965392209782e04 to your computer and use it in GitHub Desktop.
Save ashwell/53e2fe89204c74687965392209782e04 to your computer and use it in GitHub Desktop.
Simple Curry in JS
export function curry( fn, arity = fn.length ) {
let args = [];
return function curriedFn( ...newArgs ) {
args = [ ...args, ...newArgs ];
if ( args.length >= arity ) {
return fn( ...args );
}
return curriedFn;
};
}
export default curry;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment