{"id":46629,"library":"tiny-queue","title":"tiny-queue","description":"A lightweight FIFO queue implemented as a linked list, avoiding the O(n) cost of Array.shift(). Current version 0.2.1, stable but rarely updated. Differentiator: minimal overhead (~38 lines) for environments where array shift is a bottleneck, such as high-throughput message passing. Not suitable for priority queues or complex data structures.","status":"maintenance","version":"0.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/nolanlawson/tiny-queue","tags":["javascript","queue","fifo"],"install":[{"cmd":"npm install tiny-queue","lang":"bash","label":"npm"},{"cmd":"yarn add tiny-queue","lang":"bash","label":"yarn"},{"cmd":"pnpm add tiny-queue","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package does not provide ESM exports; CommonJS only.","wrong":"import Queue from 'tiny-queue';","symbol":"Queue","correct":"const Queue = require('tiny-queue');"},{"note":"Forgotten parentheses in instantiation may not fail in some contexts but is considered bad practice.","wrong":"const q = new Queue;","symbol":"Queue","correct":"const Queue = require('tiny-queue');\nconst q = new Queue();"},{"note":"If using a bundler that expects ES module default, .default may be undefined. Always fallback.","wrong":"const Queue = require('tiny-queue').default;","symbol":"Queue","correct":"const Queue = require('tiny-queue').default || require('tiny-queue');"}],"quickstart":{"code":"const Queue = require('tiny-queue');\nconst q = new Queue();\nq.push('a');\nq.push('b');\nconsole.log(q.shift()); // 'a'\nconsole.log(q.shift()); // 'b'\nconsole.log(q.shift()); // undefined\nconsole.log(q.length); // 0","lang":"javascript","description":"Shows basic push/shift FIFO behavior, including returning undefined for empty queue."},"warnings":[{"fix":"Check queue.length before calling shift if undefined is a valid value.","message":"Queue.shift returns undefined when empty, not throwing an error. This differs from some queue implementations that throw.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"None — this is expected behavior, but note for clarity.","message":"Queue.slice() returns a shallow copy of the queue as an array; mutating the returned array does not affect the original queue.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use require('tiny-queue') or configure bundler to convert CommonJS.","message":"Package does not support ES module import (no 'exports' field or ESM build). Using import Queue from 'tiny-queue' will fail in Node.js ESM or bundlers without commonjs interop.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Consider using a maintained alternative like 'denque' or 'double-ended-queue' which offer more features and TypeScript support.","message":"The package has not been updated since 2015; no TypeScript types, no ES module support, and no bug fixes for modern Node.js.","severity":"deprecated","affected_versions":">=0.1.0"}],"env_vars":null,"search_vec":"'0.2.1':22 '38':30 'array':35 'array.shift':19 'avoid':13 'bottleneck':39 'complex':53 'cost':17 'current':20 'data':54 'differenti':27 'environ':33 'fifo':6,58 'high':43 'high-throughput':42 'implement':8 'javascript':56 'lightweight':5 'line':31 'link':11 'list':12 'messag':45 'minim':28 'n':16 'o':15 'overhead':29 'pass':46 'prioriti':50 'queue':3,7,51,57 'rare':25 'shift':36 'stabl':23 'structur':55 'suitabl':48 'throughput':44 'tini':2 'tiny-queu':1 'updat':26 'version':21","created_at":"2026-06-07T13:00:52.168978+00:00","updated_at":"2026-06-07T13:00:52.168978+00:00","problems":[{"fix":"Use new Queue() instead of just Queue().","cause":"Calling Queue() without new in strict mode or ES6 class context.","error":"TypeError: Class constructor Queue cannot be invoked without 'new'"},{"fix":"Run npm install tiny-queue and ensure node_modules includes it.","cause":"Package not installed or incorrect import path.","error":"Error: Cannot find module 'tiny-queue'"}],"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/nolanlawson/tiny-queue","github":"https://github.com/nolanlawson/tiny-queue","docs":null,"changelog":null,"pypi":null,"npm":"tiny-queue","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"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}}