1.2.0 • Published 2 years ago
fast-fixed-queue v1.2.0
This is not a code created by me, I just extracted it directly from node core, as this class in particular is not exported, so I can use it on my own solutions. I did this because this queue implementation showed a really good performance over simpler ones.
How to Install
npm i fast-fixed-queue
How to use it
Instantiate it:
const queue = new FastFixedQueue<TheItemTypeYouWant>();
Enqueue items using push:
queue.push(newItem)
Dequeue items using shift:
const olderItem = queue.shift();
This implementation doesn't have a built in method to determine the queue size, but you can check if it's empty using isEmpty:
while (!queue.isEmpty()) {
console.log(queue.shift());
}
Is it worth it to use it?
We compared the performance of this package against @iter-tools/queue and native array, and the conclusions are: @iter-tools/queue got the best performance over all tested scenarios. That's why I'm deprecating that package. It doesn't worth it.
License
Licensed under MIT.