Skip to content

Instantly share code, notes, and snippets.

@maxmechanic
Created September 4, 2015 17:55
Show Gist options
  • Save maxmechanic/5e3279a73fe45af44669 to your computer and use it in GitHub Desktop.
Save maxmechanic/5e3279a73fe45af44669 to your computer and use it in GitHub Desktop.
es6 curry
// es6 riff on https://medium.com/@kevincennis/currying-in-javascript-c66080543528
function curry(fn) {
const arity = fn.length
return (function resolver(...memory) {
return function(...args) {
const local = memory.concat(args)
const next = local.length >= arity ? fn : resolver
return next(...local)
};
}());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment