Registry / storage / fifo
library2.4.1jsnpmunverified

Double-linked-list FIFO queue (v2.4.1, stable, low churn). O(1) push/shift/unshift/remove/move operations. Unlike array-based queues, removal of arbitrary nodes is O(1) by retaining node references. Supports iteration and bumping nodes to end. Minimal API, no dependencies. Suitable for high-performance queuing in Node.js or browser (bundled).

npm install fifo
INSTALL
IMPORT
SIG · FIFO
F
fifo
storagejavascriptv2.4.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ import fifo from 'fifo'
✗ const fifo = require('fifo')()
Default import is a factory function. The package ships CJS only, but ESM import works in Node 14+ with --experimental-modules or bundlers.
FIFO
✓ import fifo from 'fifo'
✗ import { FIFO } from 'fifo'
There is no named export; the default export is the constructor.
type Node
✓ import fifo from 'fifo'; const node = fifo.push('val'); // node has: value: any, prev: Node|null, next: Node|null
✗ const { Node } = require('fifo');
Node type is not exported. In TypeScript, declare interface manually or use @types/fifo.

Demonstrates basic queue operations: push, shift, first, remove, and length.

import fifo from 'fifo'; const queue = fifo(); queue.push('first'); const node = queue.push('second'); queue.push('third'); console.log(queue.shift()); // 'first' console.log(queue.first()); // 'second' queue.remove(node); console.log(queue.first()); // 'third' console.log(queue.length); // 1
Debug
Known issues
gotchaCalling fifo() multiple times creates separate instances. The default export is a factory, not a singleton.
fix
Always call fifo() to create a new instance: const q = fifo();
affects: >=2.0.0
gotchaQueue nodes have prev/next properties that should not be modified directly. Use fifo.remove() to remove nodes.
fix
Do not mutate node.prev or node.next. Use fifo.remove(node) for safe removal.
affects: >=2.0.0
gotchaCalling fifo.push() returns a node, not the value. Access value via node.value.
fix
Use const node = fifo.push('val'); const value = node.value;
affects: >=2.0.0
deprecatedThe fifo.node property is exposed but not part of the public API and may be removed in future versions.
fix
Use fifo.first() to peek at the first value, or iterate with fifo.forEach().
affects: >=2.0.0
Errors
Common errors & fixes
fifo is not a function
Forgetting to import the default export as a factory.
fix
Use const fifo = require('fifo'); const queue = fifo();
Cannot read property 'value' of undefined
Trying to access node.value on a removed node or after shift/pop returned the value.
fix
Shift returns the value directly, not a node. Use fifo.remove(node) and then node.value before removal.
TypeError: fifo.remove is not a function
Using fifo (the factory) instead of an instance.
fix
Call fifo() first: const queue = fifo(); queue.remove(node);
Upgrade
Version history
2.4.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
32 hits · last 30 days
node
30
Resources
packagefifo ↗
fifo — npm install fifo · libregistry