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

Limit function #88

Merged
merged 11 commits into from
Dec 19, 2024
Merged

Limit function #88

merged 11 commits into from
Dec 19, 2024

Conversation

liuhanqu
Copy link
Contributor

@liuhanqu liuhanqu commented Dec 3, 2024

No description provided.

readme.md Outdated
@@ -77,6 +90,28 @@ Note: This does not cancel promises that are already running.

Get or set the concurrency limit.

### limitFunction(fn, options)

Return a function with limited concurrency
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Return a function with limited concurrency
Return a function with limited concurrency.

This needs to clearly describe how it's different from the main export.

readme.md Outdated

Minimum: `1`

#### option
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover

readme.md Outdated

#### concurrency

Type: `number`(Interget)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo

readme.md Outdated
@@ -28,6 +28,19 @@ const result = await Promise.all(input);
console.log(result);
```

```js
import {limitFunction} from 'p-limit';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this example to the limitFunction API docs.

index.d.ts Outdated
@@ -41,3 +41,22 @@ Run multiple promise-returning & async functions with limited concurrency.
@returns A `limit` function.
*/
export default function pLimit(concurrency: number): LimitFunction;

export type LimitFunctionOption = {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plural

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, just name it Options as I would like to make pLimit support an options-object too, for readability.

index.d.ts Outdated
Comment on lines 53 to 58
Return a function with limited concurrency

@param function_ - Promise-returning/async function.
@param option
@return Function with limited concurrency
*/
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Return a function with limited concurrency
@param function_ - Promise-returning/async function.
@param option
@return Function with limited concurrency
*/
Return a function with limited concurrency.
@param function_ - Promise-returning/async function.
@return Function with limited concurrency.
*/

readme.md Outdated

Return a function with limited concurrency.

Note: Unlike fucntion return by `pLimit`, the return by `limitFunction` is already limited, do not need call with `limit`.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple typos and does not make it super clear what the difference is. Maybe try using ChatGPT.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be in index.d.ts too

@sindresorhus sindresorhus merged commit ef48184 into sindresorhus:main Dec 19, 2024
2 checks passed
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