sindresorhus / p-queue

Promise queue with concurrency control
MIT License
3.45k stars 185 forks source link

Add `.onSizeLessThan()` helper method #131

Closed dobesv closed 3 years ago

dobesv commented 3 years ago

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.

dobesv commented 3 years ago

I copied the readme changed over to the TS comment.

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