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 .onSizeLessThan() helper method #131

Merged
merged 8 commits into from
Mar 31, 2021

Conversation

dobesv
Copy link
Contributor

@dobesv dobesv commented Mar 26, 2021

Returns a promise that settles when the queue size is less than the given limit; queue.size < limit.

If you want to avoid having the queue grow beyond a certain size you can await queue.onSizeLessThan() before
adding a new item.

Note that this only limits the number of items waiting to start; there could still be up to concurrency jobs
already running that this call does not include in its calculation.

@sindresorhus sindresorhus changed the title Add onSizeLessThan helper method Add .onSizeLessThan() helper method Mar 28, 2021
readme.md Outdated
adding a new item.

Note that this only limits the number of items waiting to start; there could still be up to `concurrency` jobs
already running that this call does not include in its calculation.
Copy link
Owner

Choose a reason for hiding this comment

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

Can you use the same docs text here and in the TS doc comment? I know we have not done that before, but it makes it easier to keep both up to date if they are in sync.

test/test.ts Outdated Show resolved Hide resolved
@dobesv
Copy link
Contributor Author

dobesv commented Mar 31, 2021

I copied the readme changed over to the TS comment.

Let me know if there's anything else I can do to help.

@sindresorhus sindresorhus merged commit 8d0a356 into sindresorhus:main Mar 31, 2021
@dobesv dobesv deleted the backpressure branch March 31, 2021 06:18
Totenfluch pushed a commit to Totenfluch/p-queue that referenced this pull request Jul 18, 2021
Arnagos pushed a commit to Arnagos/p-queue that referenced this pull request May 2, 2022
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