Registry / testing / tiny-linked-queue

tiny-linked-queue

JSON →
library1.0.3jsnpmunverified

A lightweight, TypeScript-friendly queue implementation using a linked list, providing O(1) enqueue and dequeue operations. Compared to native arrays, it avoids the O(n) cost of Array.shift, making it ideal for high-throughput FIFO use cases. v1.0.3 is the current stable release. Ships TypeScript declarations and supports both ESM and CommonJS via conditional exports. Minimal API surface (enqueue, dequeue, clear, size, isEmpty, head, tail) with no dependencies. Bundle size gzipped < 1KB.

npm install tiny-linked-queue
INSTALL
IMPORT
SIG · TINY-LINKED-QUEUE
T
tiny-linked-queue
testingjavascriptv1.0.3
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
✓ import Queue from 'tiny-linked-queue';
✗ const Queue = require('tiny-linked-queue');
Default import works in ESM and TypeScript; require still works in CommonJS.
Queue (as type)
✓ import type Queue from 'tiny-linked-queue';
For TypeScript type-only imports when you only need the type.
Queue (namespace import)
✓
✗ import * as q from 'tiny-linked-queue';
Default export is not a namespace; this will cause a runtime error. Use default import instead.

Creates a queue, enqueues elements, checks properties, dequeues, and clears. Demonstrates generic typing and all main methods.

import Queue from 'tiny-linked-queue'; const q = new Queue<number>(); q.enqueue(1); q.enqueue(2); q.enqueue(3); console.log(q.size); // 3 console.log(q.head); // 1 console.log(q.tail); // 3 const first = q.dequeue(); // 1 console.log(first); console.log(q.size); // 2 console.log(q.isEmpty); // false q.clear(); console.log(q.isEmpty); // true
Debug
Known issues
breakingExport changed from CommonJS module.exports to named export Queue in version 1.0.0. Prior versions used a different export pattern.
fix
Update import to use default import: import Queue from 'tiny-linked-queue'
affects: <1.0.0
gotchaThe property names 'head' and 'tail' expose internal linked-list nodes directly. Modifying these objects may break queue integrity.
fix
Treat head and tail as read-only. Do not mutate returned values.
affects: >=1.0.0
gotchaCalling dequeue on an empty queue returns undefined, not throwing an error. This may hide bugs if not checking isEmpty first.
fix
Always check isEmpty before calling dequeue, or handle undefined returns explicitly.
affects: >=1.0.0
deprecatedThe constructor currently accepts no arguments. Passing arguments will be silently ignored, but future versions may throw.
fix
Do not pass arguments to new Queue().
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Queue is not a constructor
Using named import instead of default import in CommonJS/ESM.
fix
Use import Queue from 'tiny-linked-queue' instead of import { Queue } from 'tiny-linked-queue'.
Cannot read properties of undefined (reading 'enqueue')
Import resolved to undefined due to incorrect import syntax (e.g., import * as Q from 'tiny-linked-queue').
fix
Use import Queue from 'tiny-linked-queue' to get the class constructor.
Property 'size' does not exist on type 'Queue<unknown>'
TypeScript version older than 3.8 or missing 'useDefineForClassFields' may cause property access issues.
fix
Upgrade TypeScript to >=3.8 or set useDefineForClassFields: true in tsconfig.json.
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

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