Skip to content

Instantly share code, notes, and snippets.

@bitfishxyz
Created January 19, 2020 02:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bitfishxyz/4f814d7a74b708875079c20840929b4f to your computer and use it in GitHub Desktop.
Save bitfishxyz/4f814d7a74b708875079c20840929b4f to your computer and use it in GitHub Desktop.
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