Skip to content

Instantly share code, notes, and snippets.

@edfuh
Created August 26, 2011 22:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edfuh/1174626 to your computer and use it in GitHub Desktop.
Save edfuh/1174626 to your computer and use it in GitHub Desktop.
curry
//extend native. bad?
Function.prototype.curry = function () {
var aslice = [].slice, _method = this, args = aslice.call(arguments);
if (!args.length) return _method;
return function () {
var a = args.concat(aslice.call(arguments));
return _method.apply(this, a);
}
}
//as function. better
curry = function (func, args) {
var aslice = [].slice, _method = func, args = aslice.call(arguments, 1);
if (!args.length) return _method;
return function () {
var a = args.concat(aslice.call(arguments));
return _method.apply(this, a);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment