p-queue
p-queue copied to clipboard
Feature request: onSize promise
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.
This has been added in the latest release.
For size < limit, use .onSizeLessThan:
await queue.onSizeLessThan(limit)
For size <= limit:
await queue.onSizeLessThan(limit + 1)