Created
January 19, 2020 02:24
-
-
Save bitfishxyz/4f814d7a74b708875079c20840929b4f to your computer and use it in GitHub Desktop.
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) { | |
if (fn.length <= 1) return fn; | |
const generator = (...args) => { | |
if (fn.length === args.length) { | |
return fn(...args) | |
} else { | |
return (...args2) => { | |
return generator(...args, ...args2) | |
} | |
} | |
} | |
return generator | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment