Skip to content

Instantly share code, notes, and snippets.

@vvatikiotis
Forked from ericelliott/autocurry.js
Created July 3, 2018 11:09
Show Gist options
  • Save vvatikiotis/c7e71e612ff4b9a6cd7cf721cdd4227b to your computer and use it in GitHub Desktop.
Save vvatikiotis/c7e71e612ff4b9a6cd7cf721cdd4227b to your computer and use it in GitHub Desktop.
Autocurry
const curry = fn => (...args1) => {
if (args1.length === fn.length) {
return fn(...args1);
}
return (...args2) => {
const args = [...args1, ...args2];
if (args.length >= fn.length) {
return fn(...args);
}
return curry(fn)(...args);
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment