Created
June 19, 2018 10:40
-
-
Save alenaksu/f447546486bd7608a917235d341c7e36 to your computer and use it in GitHub Desktop.
js currying
This file contains hidden or 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
function curry(fn) { | |
function nest(...args) { | |
const next = this.bind(this, ...args); | |
if (args.length === 0 || next.length === 0) { | |
return next(); | |
} else { | |
return nest.bind(next); | |
} | |
} | |
return nest.bind(fn); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment