A simple priority queue (binary heap) implementation for Node.js and browsers. Stable version 2.0.0 (latest release); no longer actively developed but functional. It provides a straightforward API with custom comparator support and default comparator for numbers/strings. Differentiator: minimalistic, no dependencies, suitable for small projects. However, it lacks TypeScript types and modern ESM support, and the stable API has been unchanged for years.
npm install priorityqueuejsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a priority queue with a custom comparator for objects, enqueues three items, and demonstrates peek, deq, and size.
Ensure the comparator returns a number, e.g., a - b for numbers.
Consider using modern alternatives like @datastructures-js/priority-queue or heap.
Avoid modifying elements inside forEach. If you must, recreate the queue after changes.
Use require: var PriorityQueue = require('priorityqueuejs');Use require or configure webpack to handle CommonJS modules.
Check isEmpty() before calling deq() or peek().
Ensure comparator returns a numeric value: return a - b (for ascending) or b - a (for descending).
No dependency data recorded yet.