Registry / testing / tiny-queue

tiny-queue

JSON →
library0.2.1jsnpmunverified

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.

npm install tiny-queue
INSTALL
IMPORT
SIG · TINY-QUEUE
T
tiny-queue
testingjavascriptv0.2.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.

Queue
✓ const Queue = require('tiny-queue');
✗ import Queue from 'tiny-queue';
Package does not provide ESM exports; CommonJS only.
Queue
✓ const Queue = require('tiny-queue'); const q = new Queue();
✗ const q = new Queue;
Forgotten parentheses in instantiation may not fail in some contexts but is considered bad practice.
Queue
✓ const Queue = require('tiny-queue').default || require('tiny-queue');
✗ const Queue = require('tiny-queue').default;
If using a bundler that expects ES module default, .default may be undefined. Always fallback.

Shows basic push/shift FIFO behavior, including returning undefined for empty queue.

const Queue = require('tiny-queue'); const q = new Queue(); q.push('a'); q.push('b'); console.log(q.shift()); // 'a' console.log(q.shift()); // 'b' console.log(q.shift()); // undefined console.log(q.length); // 0
Debug
Known issues
gotchaQueue.shift returns undefined when empty, not throwing an error. This differs from some queue implementations that throw.
fix
Check queue.length before calling shift if undefined is a valid value.
affects: >=0.1.0
gotchaQueue.slice() returns a shallow copy of the queue as an array; mutating the returned array does not affect the original queue.
fix
None — this is expected behavior, but note for clarity.
affects: >=0.1.0
gotchaPackage 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.
fix
Use require('tiny-queue') or configure bundler to convert CommonJS.
affects: >=0.1.0
deprecatedThe package has not been updated since 2015; no TypeScript types, no ES module support, and no bug fixes for modern Node.js.
fix
Consider using a maintained alternative like 'denque' or 'double-ended-queue' which offer more features and TypeScript support.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: Class constructor Queue cannot be invoked without 'new'
Calling Queue() without new in strict mode or ES6 class context.
fix
Use new Queue() instead of just Queue().
Error: Cannot find module 'tiny-queue'
Package not installed or incorrect import path.
fix
Run npm install tiny-queue and ensure node_modules includes it.
Upgrade
Version history
0.2.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
tiny-queue — npm install tiny-queue · libregistry