A simple asynchronous priority queue for Node.js (v1.0.1). Items are inserted in sorted order using a custom comparator (default descending). The take() method returns a Promise that resolves to the next highest-priority item, blocking if the queue is empty until an item is put. Supports multiple blocked takers. Lightweight, no dependencies, CJS only. Differentiators: minimal API (put/take/size/takersBlocked), comparator is maximum-oriented (item with largest comparator value is taken first). Not compatible with ESM imports.
npm install priority-blocking-queueNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows instantiation with comparator, adding multiple items at once, and asynchronous consumption with blocking.
Reverse comparator logic if you want min-priority queue: (lhs, rhs) => rhs.p - lhs.p.
Use await queue.put(item) only if you need to wait for space (not implemented); simply call queue.put(item1, item2, ...).
Use put() instead of add().
If you need a timeout, wrap take() with Promise.race and a timeout Promise.
Use require() instead of import.
Use const PriorityBlockingQueue = require('priority-blocking-queue');Reverse comparator: (lhs, rhs) => rhs.p - lhs.p for min-priority.
Check that require returns the constructor: const PriorityBlockingQueue = require('priority-blocking-queue');No dependency data recorded yet.