Skip to content

Instantly share code, notes, and snippets.

@EminQasimov
Created April 22, 2019 15:33
Show Gist options
  • Save EminQasimov/7aef9becdf4b0956e747613235805868 to your computer and use it in GitHub Desktop.
Save EminQasimov/7aef9becdf4b0956e747613235805868 to your computer and use it in GitHub Desktop.
Currying
function curry( fn ) {
var arity = fn.length;
return (function resolver() {
var memory = Array.prototype.slice.call( arguments );
return function() {
var local = memory.slice(), next;
Array.prototype.push.apply( local, arguments );
next = local.length >= arity ? fn : resolver;
return next.apply( null, local );
};
}());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment