Package Exports
- tiny-queue
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (tiny-queue) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
tiny-queue
A simple FIFO queue implementation to avoid having to do shift()
on an array, which is slow. It's implemented in the straightforward root -> node1 -> node2 -> etc.
architecture that we all wrote in CS 101.
This can typically be used as a drop-in replacement for an array, and it's only 24 lines of code.
Usage:
npm install tiny-queue
Then:
var Queue = require('tiny-queue');
var queue = new Queue();
queue.push('foo');
queue.push('bar');
queue.shift(); // 'foo'
queue.shift(); //'bar'
queue.length; // 0
queue.shift(); // undefined
The returned Queue
object, once instantiated, only supports
three operations:
queue.push()
queue.shift()
queue.length
So it's basically a drop-in replacement for most naïve usages of an array as a queue.