{"id":44947,"library":"fifo","title":"fifo","description":"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).","status":"active","version":"2.4.1","language":"javascript","source_language":"en","source_url":"https://github.com/mafintosh/fifo","tags":["javascript"],"install":[{"cmd":"npm install fifo","lang":"bash","label":"npm"},{"cmd":"yarn add fifo","lang":"bash","label":"yarn"},{"cmd":"pnpm add fifo","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default import is a factory function. The package ships CJS only, but ESM import works in Node 14+ with --experimental-modules or bundlers.","wrong":"const fifo = require('fifo')()","symbol":"default","correct":"import fifo from 'fifo'"},{"note":"There is no named export; the default export is the constructor.","wrong":"import { FIFO } from 'fifo'","symbol":"FIFO","correct":"import fifo from 'fifo'"},{"note":"Node type is not exported. In TypeScript, declare interface manually or use @types/fifo.","wrong":"const { Node } = require('fifo');","symbol":"type Node","correct":"import fifo from 'fifo';\nconst node = fifo.push('val');\n// node has: value: any, prev: Node|null, next: Node|null"}],"quickstart":{"code":"import fifo from 'fifo';\n\nconst queue = fifo();\nqueue.push('first');\nconst node = queue.push('second');\nqueue.push('third');\nconsole.log(queue.shift()); // 'first'\nconsole.log(queue.first()); // 'second'\nqueue.remove(node);\nconsole.log(queue.first()); // 'third'\nconsole.log(queue.length); // 1","lang":"typescript","description":"Demonstrates basic queue operations: push, shift, first, remove, and length."},"warnings":[{"fix":"Always call fifo() to create a new instance: const q = fifo();","message":"Calling fifo() multiple times creates separate instances. The default export is a factory, not a singleton.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Do not mutate node.prev or node.next. Use fifo.remove(node) for safe removal.","message":"Queue nodes have prev/next properties that should not be modified directly. Use fifo.remove() to remove nodes.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Use const node = fifo.push('val'); const value = node.value;","message":"Calling fifo.push() returns a node, not the value. Access value via node.value.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Use fifo.first() to peek at the first value, or iterate with fifo.forEach().","message":"The fifo.node property is exposed but not part of the public API and may be removed in future versions.","severity":"deprecated","affected_versions":">=2.0.0"}],"env_vars":null,"search_vec":"'1':13,27 'api':40 'arbitrari':23 'array':18 'array-bas':17 'base':19 'browser':52 'bump':35 'bundl':53 'churn':11 'depend':42 'doubl':3 'double-linked-list':2 'end':38 'fifo':1,6 'high':46 'high-perform':45 'iter':33 'javascript':54 'link':4 'list':5 'low':10 'minim':39 'node':24,30,36 'node.js':50 'o':12,26 'oper':15 'perform':47 'push/shift/unshift/remove/move':14 'queu':48 'queue':7,20 'refer':31 'remov':21 'retain':29 'stabl':9 'suitabl':43 'support':32 'unlik':16 'v2.4.1':8","created_at":"2026-06-07T12:52:37.329600+00:00","updated_at":"2026-06-07T12:52:37.329600+00:00","problems":[{"fix":"Use const fifo = require('fifo'); const queue = fifo();","cause":"Forgetting to import the default export as a factory.","error":"fifo is not a function"},{"fix":"Shift returns the value directly, not a node. Use fifo.remove(node) and then node.value before removal.","cause":"Trying to access node.value on a removed node or after shift/pop returned the value.","error":"Cannot read property 'value' of undefined"},{"fix":"Call fifo() first: const queue = fifo(); queue.remove(node);","cause":"Using fifo (the factory) instead of an instance.","error":"TypeError: fifo.remove is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/mafintosh/fifo","github":"https://github.com/mafintosh/fifo","docs":null,"changelog":null,"pypi":null,"npm":"fifo","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}