A priority queue data structure library for JavaScript (v0.1.5) offering Array, BinaryHeap, and BHeap strategies. Provides standard operations: queue, dequeue, peek, clear, and length. Ideal for managing ordered data efficiently; defaults to BinaryHeap for O(log n) insert and extract. Lightweight, dependency-free, works in Node.js and browsers via CommonJS/AMD/global. Last updated in 2014, considered stable but unmaintained.
npm install js-priority-queueNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a min-heap priority queue with initial values, queues an element, dequeues smallest elements, and clears the queue.
Use CommonJS require or configure bundler to handle CJS.
Add custom type declarations or use @types/js-priority-queue if available (none exists).
Always provide a comparator function.
Use BinaryHeapStrategy (default) for most cases.
Consider modern alternatives like @datastructures-js/priority-queue or flatqueue.
Use `const PriorityQueue = require('js-priority-queue');` or configure bundler for CJS.Use one of: PriorityQueue.ArrayStrategy, PriorityQueue.BinaryHeapStrategy, PriorityQueue.BHeapStrategy.
Provide a comparator function like `(a, b) => a - b`.
Ensure queue was created correctly: `const queue = new PriorityQueue({ comparator: ... });`No dependency data recorded yet.