Created
September 4, 2015 17:55
-
-
Save maxmechanic/5e3279a73fe45af44669 to your computer and use it in GitHub Desktop.
es6 curry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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