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

Add pThrottleConcurrency and make pThrottle a named export pThrottleRate #41

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Richienb
Copy link
Contributor

concept art

Fixes sindresorhus/promise-fun#23

@sindresorhus
Copy link
Owner

What's your reasoning for making it two separate functions?

@@ -82,4 +82,50 @@ for (let index = 1; index <= 6; index++) {
//=> 6: 2s
```
*/
export default function pThrottle(options: Options): <F extends AnyFunction>(function_: F) => ThrottledFunction<F>;
export function pThrottleRate(options: RateOptions): <F extends AnyFunction>(function_: F) => ThrottledFunction<F>;
Copy link
Owner

Choose a reason for hiding this comment

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

Since it's a named function, can drop the prefix:

Suggested change
export function pThrottleRate(options: RateOptions): <F extends AnyFunction>(function_: F) => ThrottledFunction<F>;
export function throttleRate(options: RateOptions): <F extends AnyFunction>(function_: F) => ThrottledFunction<F>;

@Richienb
Copy link
Contributor Author

Richienb commented Nov 27, 2023

What's your reasoning for making it two separate functions?

  1. One controls how often it is called
  2. The other controls how many calls are running

It seems a bit of a bad idea to mix them - but I suppose it would be convenient to, will investigate.

@sindresorhus
Copy link
Owner

Any plans to move this forward or should I close?

@Richienb
Copy link
Contributor Author

will continue when I have time
paso a paso

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.

p-* version for promise-queue(max-concurrent=1, max-lenght=1)
2 participants