Created
May 5, 2024 09:46
-
-
Save amitasaurus/bc6c312b63d3a2d55892de9e6c494418 to your computer and use it in GitHub Desktop.
Implementation of curry in TS
This file contains 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
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