A generic FIFO queue data structure.
Prerequisites
npm install --save phosphor-queue
Prerequisites
git clone https://github.com/phosphorjs/phosphor-queue.git
cd phosphor-queue
npm install
Rebuild
npm run clean
npm run build
Follow the source build instructions first.
npm test
Follow the source build instructions first.
npm run docs
Navigate to docs/index.html
.
The runtime versions which are currently known to work are listed below. Earlier versions may also work, but come with no guarantees.
- Node 0.12.7+
- IE 11+
- Firefox 32+
- Chrome 38+
Follow the package install instructions first.
npm install --save-dev browserify browserify-css
browserify -g browserify-css myapp.js -o mybundle.js
Note: This module is fully compatible with Node/Babel/ES6/ES5. Simply omit the type declarations when using a language other than TypeScript.
import { Queue } from 'phosphor-queue';
var q = new Queue<number>([0, 1, 2, 3]);
q.front; // 0
q.back; // 3
q.size; // 4
q.empty; // false
q.pop(); // 0
q.pop(); // 1
q.pop(); // 2
q.pop(); // 3
q.pop(); // undefined
q.front; // undefined
q.back; // undefined
q.size; // 0
q.empty; // true
q.push(42);
q.push(43);
q.push(44);
q.push(44);
q.push(45);
q.toArray(); // [42, 43, 44, 44, 45]
q.remove(42); // true
q.remove(19); // false
q.removeAll(44); // 2
q.removeAll(19); // 0
q.toArray(); // [43, 45]
q.clear();
q.size; // 0
q.empty; // true
q.push(42);
q.push(43);
q.push(44);
q.push(45);
q.some(v => v < 40); // false
q.some(v => v > 44); // true
q.every(v => v > 40); // true
q.every(v => v > 44); // false
q.filter(v => v < 40); // []
q.filter(v => v > 44); // [45]
q.map(v => v * 2); // [84, 86, 88, 90]
q.forEach((v, i) => {
console.log(v, i);
});
var index = q.forEach((v, i) => {
if (v === 43) return i;
});
index; // 1