1.5.0 • Published 4 years ago

simple-priority-queue v1.5.0

Weekly downloads
5
License
ISC
Repository
github
Last release
4 years ago

Priority Queue

Simple and fast priority queue that uses promise based of while iteration and not blocking the main thread.

NPM JavaScript Style Guide

Contents

Install

npm i --save simple-priority-queue

Basic Usage

const { PriorityQueue } = require('simple-priority-queue');

const myQueue = new PriorityQueue(true); //true for maxheap, default is minheap
// enqueue recive 2 params nodeData: any object , nodePriority: priority of data
myQueue.insert({ myCoolData: 'MyCoolValue' }, 1);
myQueue.insert({ myCoolData: 'MyCoolValue' }, 2);
myQueue.insert({ myCoolData: 'MyCoolValue' }, 3);
myQueue.insert({ myCoolData: 'MyCoolValue' }, 4);
// dequeue by order of the priority
const value = myQueue.poll();

// sort the data (will remove the content of queue)
const mySortedArray = await myQueue.heapSort();

License

MIT © https://github.com/Naihan/simple-priority-queue

1.5.0

4 years ago

1.4.0

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.3.0

4 years ago

1.0.0

4 years ago