GT2/GT2-iOS/node_modules/tiny-queue
Ren Ren Juan 30eef7d036 correct tree err 2018-02-12 17:26:06 +00:00
..
.npmignore correct tree err 2018-02-12 17:26:06 +00:00
LICENSE correct tree err 2018-02-12 17:26:06 +00:00
README.md correct tree err 2018-02-12 17:26:06 +00:00
index.js correct tree err 2018-02-12 17:26:06 +00:00
package.json correct tree err 2018-02-12 17:26:06 +00:00
test.js correct tree err 2018-02-12 17:26:06 +00:00

README.md

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 remember from CS 101.

This can typically be used as a drop-in replacement for an array, and it's only 38 lines of code.

Status

browser support

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

API

The returned Queue object, once instantiated, only supports four operations:

queue.push()
queue.shift()
queue.slice() // returns a regular Array
queue.length

So it's basically a drop-in replacement for most naïve usages of an array as a queue.