New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@practicaljs/priority-queue

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@practicaljs/priority-queue - npm Package Compare versions

Comparing version
1.0.0
to
1.1.0
+6
-1
package.json
{
"name": "@practicaljs/priority-queue",
"version": "1.0.0",
"version": "1.1.0",
"license": "MIT",
"type": "module",
"author": {
"name": "Harlen Alvarez",
"email": "halvarez18@msn.com",
"url": "https://github.com/harlenalvarez"
},
"description": "Javascript / Typescript priority queue ( max / min heap )",

@@ -7,0 +12,0 @@ "exports": {

@@ -121,2 +121,26 @@ <a name="readme-top"></a>

//[{ name: 'Special - House Music', time: 22 }, { name: 'Special - Live Music', time: 23 }, { name: 'breakfast', time: 7}...]
```
```
You can also check and remove specific items if you provide a key to track
```ts
const foodLikes = [
{ name: 'sushi', rating: 4 },
{ name: 'chicken', rating: 4 },
{ name: 'beef', rating: 5 },
{ name: 'pork', rating: 1 }
];
// we'll track our objects by name ( this makes name unique )
const queue = new PriorityQueue<typeof foodLikes[0]>(
(a, b) => a.rating - b.rating,
// Method takes the item and must return a string
(item) => item.name
);
for (let food of foodLikes) {
queue.enqueue(food);
}
// you can check if an item exists ( only if the key method was provided )
if(queue.hasItem(foodLikes[3]))
const pork = queue.dequeueItem(foodLikes[3]);
```
> If you provide a key to track it will also check for uniqueness when enqueing items and ignore if the item you are adding already exists and it's comparison value is the same