Priority Blocking Queue
A simple priority blocking queue. Items are sorted as they're added to the queue. Takers always remove items in sorted order, and block on an empty queue, waiting for a new item to be added.
Installation
npm install --save priority-blocking-queue
API
Add items to the queue and then remove them in sorted order.
const PriorityBlockingQueue = ;let queue = lhsp - rhsp;queue; let a = await queue;console;// 3 let b = await queue;console;// 2 let c = await queue;console;// 1
Wait for an item to become available.
const PriorityBlockingQueue = ;let queue = lhsp - rhsp;queue;queue; console;// 0 console;// 2 ; // taker 1 got 3// taker 2 got 2