Skip to content

Instantly share code, notes, and snippets.

@slugbyte
Created September 15, 2017 22:29
Show Gist options
  • Save slugbyte/2b1e5ebde3214e3ec82566e08787cafc to your computer and use it in GitHub Desktop.
Save slugbyte/2b1e5ebde3214e3ec82566e08787cafc to your computer and use it in GitHub Desktop.
let curry = (fn, ...defaults) => {
if(typeof fn !== 'function') throw new Error('Expected a function')
if(fn.length < 2) return fn
if(defaults.length >= fn.length) return fn(...defaults)
return (...args) => curry(fn, ...defaults.concat(args))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment