Created
July 31, 2015 09:34
-
-
Save zbinlin/b76f70dd2e73d2313cfa to your computer and use it in GitHub Desktop.
auto currying
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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