Skip to content

Instantly share code, notes, and snippets.

@cuipengfei
Created December 15, 2013 15:57
Show Gist options
  • Select an option

  • Save cuipengfei/7974641 to your computer and use it in GitHub Desktop.

Select an option

Save cuipengfei/7974641 to your computer and use it in GitHub Desktop.
functional js curry
function curryN(fn, n) {
function wrapper(args) {
return function (oneArg) {
var argsConcat = args.concat(oneArg)
if (argsConcat.length == ( n || fn.length)) {
return fn.apply(this, argsConcat)
}
return wrapper(argsConcat)
}
}
return wrapper([])
}
module.exports = curryN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment