Skip to content

Instantly share code, notes, and snippets.

@ericelliott
Created January 28, 2017 05:35
Show Gist options
  • Save ericelliott/eb176261f41d82c02460a2756fe8911a to your computer and use it in GitHub Desktop.
Save ericelliott/eb176261f41d82c02460a2756fe8911a 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