A tiny, fast queue data structure for JavaScript/TypeScript (v3.2.2, updated 2024). Provides O(1) push/pop operations as an alternative to Array#shift() which is O(n). ESM-only, ships TypeScript declarations, no dependencies. Iterable, with push, pop, clear, and size. Ideal for high-frequency enqueue/dequeue patterns like breadth-first search or stream buffering.
npm install queue-litNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a queue, pushes items, iterates, pops, clears, and shows size in TypeScript.
Use import instead of require(). Ensure your project is configured for ESM (e.g., type: module in package.json, .mjs extension, or Node >=18 with experimental modules).
Change `import Queue from 'queue-lit'` to `import { Queue } from 'queue-lit'`.Use `queue.size` instead of `Queue.size` or `queue.size()`.
Check queue.size before popping or handle undefined return values.
Use for...of or spread operator to iterate. Do not call .next() on the queue directly.
When breaking early, consider using queue.clear() if needed. Otherwise, no side effects expected.
Replace `const { Queue } = require('queue-lit')` with `import { Queue } from 'queue-lit'` and ensure your project is ESM-compatible.Use `import { Queue } from 'queue-lit'` instead of `import Queue from 'queue-lit'`.Ensure you have created an instance: `const queue = new Queue();` and that you imported Queue correctly.
Use for...of, spread, or convert to array with Array.from(queue) instead of calling .next().
No dependency data recorded yet.