Skip to content

Instantly share code, notes, and snippets.

@zbinlin
Created July 31, 2015 09:34
Show Gist options
  • Save zbinlin/b76f70dd2e73d2313cfa to your computer and use it in GitHub Desktop.
Save zbinlin/b76f70dd2e73d2313cfa to your computer and use it in GitHub Desktop.
auto currying
/**
* Auto Currying
* @param {Function} fn
* @return {Function}
*/
function curring(fn) {
var fnLength = fn.length;
return (function next(argv) {
return function () {
([]).push.apply(argv, arguments);
return (argv.length >= fnLength || arguments.length === 0) ? fn.apply(this, argv) : next(argv);
};
}([]));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment