🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

p-queue

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

p-queue - npm Package Compare versions

Comparing version
9.3.0
to
9.3.1
+13
-5
dist/index.js

@@ -517,7 +517,10 @@ import { EventEmitter } from 'eventemitter3';

async onSizeLessThan(limit) {
// Instantly resolve if the queue is empty.
// Instantly resolve if the size is already below the limit.
if (this.#queue.size < limit) {
return;
}
await this.#onEvent('next', () => this.#queue.size < limit);
// Listen on both `'next'` (task completion, queued abort, `clear()`) and `'active'` (every dequeue),
// so waiters wake even when the queue drains without a completion (`start()`, a runtime `concurrency`
// increase, or an interval tick).
await this.#onEvent(['next', 'active'], () => this.#queue.size < limit);
}

@@ -604,3 +607,4 @@ /**

}
async #onEvent(event, filter) {
async #onEvent(events, filter) {
const eventList = Array.isArray(events) ? events : [events];
return new Promise(resolve => {

@@ -611,6 +615,10 @@ const listener = () => {

}
this.off(event, listener);
for (const event of eventList) {
this.off(event, listener);
}
resolve();
};
this.on(event, listener);
for (const event of eventList) {
this.on(event, listener);
}
});

@@ -617,0 +625,0 @@ }

{
"name": "p-queue",
"version": "9.3.0",
"version": "9.3.1",
"description": "Promise queue with concurrency control",

@@ -5,0 +5,0 @@ "license": "MIT",