fast-fifo
A fast fifo implementation similar to the one powering nextTick in Node.js core
npm install fast-fifoUses a linked list of growing fixed sized arrays to implement the FIFO to avoid allocating a wrapper object for each item.
Usage
const FIFO = require('fast-fifo')
const q = new FIFO()
q.push('hello')
q.push('world')
q.shift() // returns hello
q.shift() // returns worldAPI
q = new FIFO()
q = new FIFO()Create a new FIFO.
q.push(value)
q.push(value)Push a value to the FIFO. value can be anything other than undefined.
value = q.shift()
value = q.shift()Return the oldest value from the FIFO.
q.clear()
q.clear()Remove all values from the FIFO.
bool = q.isEmpty()
bool = q.isEmpty()Returns true if the FIFO is empty and false otherwise.
value = q.peek()
value = q.peek()Return the oldest value from the FIFO without shifting it out.
len = q.length
len = q.lengthGet the number of entries remaining in the FIFO.
Benchmarks
Included in bench.js is a simple benchmark that benchmarks this against a simple linked list based FIFO.
On my machine the benchmark looks like this:
YMMV
License
MIT
Previousfast-deep-equalNextJAEGIS-METHOD-v2.0\v2.1.1\JAEGIS\JAEGIS_Core\JAEGIS-METHOD\node_modules\fast-levenshtein\LICENSE
Last updated