Skip to content

Instantly share code, notes, and snippets.

@amitasaurus
Created May 5, 2024 09:46
Show Gist options
  • Save amitasaurus/bc6c312b63d3a2d55892de9e6c494418 to your computer and use it in GitHub Desktop.
Save amitasaurus/bc6c312b63d3a2d55892de9e6c494418 to your computer and use it in GitHub Desktop.
Implementation of curry in TS
export default function curry(func: Function): Function {
return function curried(this: any, ...args: any[]) {
if (args.length >= func.length) {
return func.apply(this, args);
} else {
return function (this: any, ...args1: any[]) {
return curried.apply(this, args.concat(args1));
};
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment