Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

mass2527
Copy link
Contributor

I've updated the documentation to fix inaccuracies and improve readability. I also removed sections that I think are unnecessary.

Copy link

vercel bot commented Sep 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
es-toolkit ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 16, 2024 6:27am

Comment on lines -112 to -135
/**
* 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;
Copy link
Contributor Author

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-commenter
Copy link

codecov-commenter commented Sep 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.23%. Comparing base (e37b295) to head (6c8f0ff).

Additional details and impacted files

Impacted file tree graph

@@            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              

Comment on lines -136 to -159

/**
* 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);
*/
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants