
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
priority_queue
Advanced tools
h1. Priority Queue
A simple javascript priority queue using a binary heap. A compare function is used to sort the elements. The queue works in CommonJS and browser environments.
h2. Synopsis
bc.. var pq = require('priority_queue');
// create a queue var q = new pq.PriorityQueue();
// push some elements q.push(42, 5, 23, Math.PI);
// shift 'em out ... while (q.length > 0) { console.log(q.shift()); }
h2. Installation
bc. npm install priority_queue
To use the queue in a web page add
bc.
The module is exported as @agnat_priority_queue@.
h2. Documentation
h3. pq.PriorityQueue(compare, queue)
Construct a new priority queue. @compare@ is a function with the same semantics as the "compare functions":https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/sort used with @Array.sort()@. It defaults to a simple numeric comparison with ascending order.
An initial queue array may be passed in using the @queue@ argument. Note that the content of the array will be modified.
The constructor may be called with or without operator @new@.
h3. queue.push(element, ...)
Add new elements to the queue. Returns the new length.
h3. queue.shift()
Remove the item with maximum priority from the queue and return it.
h3. queue.length
The current length of the queue.
h3. Compare Functions
Two compare functions are included. They are not very useful because they only compare numbers. However, they are used in testing and provide a starting point to implement your own.
h4. pq.min_first
Return items with minimum priority first
h4. pq.max_first
Return items with maximum priority first
h2. License
MIT.
FAQs
simple priority queue using a binary heap
The npm package priority_queue receives a total of 2 weekly downloads. As such, priority_queue popularity was classified as not popular.
We found that priority_queue demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.