// the find
lemire/FastPriorityQueue.js
a fast heap-based priority queue in JavaScript
A binary min-heap implementation in JavaScript, optimized for raw throughput. It's a single-file library with no dependencies, aimed at anyone who has benchmarked the alternatives and found them too slow — graph traversal, scheduling, simulation engines.
The `replaceTop` operation is the standout: poll + add in one heap traversal, which is the critical path for top-k queries and gives 4-5x the throughput of doing both separately. The benchmark suite is honest — includes competitors and shows where it actually loses. The `removeMany` and `removeOne` callbacks let you do filtered bulk removal without converting to an array and back. TypeScript definitions are included, which saves the usual `@types/` hunt.
No stable ordering — equal-priority elements can come out in arbitrary order, and the README says so but doesn't offer a workaround (that's what StablePriorityQueue is for, though you have to go find it yourself). The `remove(value)` method does a linear scan to find the element, so it's O(n) — fine if you rarely remove mid-queue, a problem if you do it frequently. The benchmarks are from Node 14-15 vintage; V8 has changed substantially since then and the numbers may not hold. No support for updating the priority of an existing element, which rules it out for Dijkstra and similar algorithms without external bookkeeping.