-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs(curry): Update docs for curry
#541
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
/** | ||
* Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. | ||
* This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. | ||
* | ||
* @param {(...args: any[]) => any} func - The function to curry. | ||
* @returns {(...args: any[]) => any} A curried function that can be called with a single argument at a time. | ||
* | ||
* @example | ||
* function sum(a: number, b: number, c: number) { | ||
* return a + b + c; | ||
* } | ||
* | ||
* const curriedSum = curry(sum); | ||
* | ||
* // The parameter `a` should be given the value `10`. | ||
* const sum10 = curriedSum(10); | ||
* | ||
* // The parameter `b` should be given the value `15`. | ||
* const sum25 = sum10(15); | ||
* | ||
* // The parameter `c` should be given the value `5`. The function 'sum' has received all its arguments and will now return a value. | ||
* const result = sum25(5); | ||
*/ | ||
export function curry(func: (...args: any[]) => any): (...args: any[]) => any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if we don’t support more than 5 parameters, we don’t need to write an overload signature for it. I think not supporting it is better than supporting it with incorrect types. What do you think about this?
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #541 +/- ##
==========================================
- Coverage 99.29% 99.23% -0.06%
==========================================
Files 220 220
Lines 1835 1835
Branches 500 500
==========================================
- Hits 1822 1821 -1
- Misses 12 13 +1
Partials 1 1 |
|
||
/** | ||
* Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. | ||
* This process continues until all arguments have been provided, at which point the original function is called with all accumulated arguments. | ||
* | ||
* @param {(...args: any[]) => any} func - The function to curry. | ||
* @returns {(...args: any[]) => any} A curried function that can be called with a single argument at a time. | ||
* | ||
* @example | ||
* function sum(a: number, b: number, c: number) { | ||
* return a + b + c; | ||
* } | ||
* | ||
* const curriedSum = curry(sum); | ||
* | ||
* // The parameter `a` should be given the value `10`. | ||
* const sum10 = curriedSum(10); | ||
* | ||
* // The parameter `b` should be given the value `15`. | ||
* const sum25 = sum10(15); | ||
* | ||
* // The parameter `c` should be given the value `5`. The function 'sum' has received all its arguments and will now return a value. | ||
* const result = sum25(5); | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the overloaded signatures already have good JSDoc, we can delete this jsdoc of function implementation and keep only the necessary sections.
I've updated the documentation to fix inaccuracies and improve readability. I also removed sections that I think are unnecessary.