p-queue icon indicating copy to clipboard operation
p-queue copied to clipboard

Feature request: onSize promise

Open Azmisov opened this issue 4 years ago • 1 comments

How about having another onSize(limit) promise, which resolves when size <= limit? You already have onEmpty and onIdle. Personally I don't want to queue 100k+ promises right at the start. So would be nice to be able to queue them on demand when queue size drops below say 2x concurrency.

Could perhaps consider onSizeBy(limit, options) as well.

Azmisov avatar Mar 12 '21 20:03 Azmisov

This has been added in the latest release.

dobesv avatar Apr 09 '21 16:04 dobesv

For size < limit, use .onSizeLessThan:

await queue.onSizeLessThan(limit)

For size <= limit:

await queue.onSizeLessThan(limit + 1)

Richienb avatar Sep 06 '22 06:09 Richienb