elegant-queue (v1.0.9) is a high-performance queue implementation for JavaScript and TypeScript that uses a linked list of fixed-size arrays (circular buffers) to achieve O(1) enqueue and dequeue operations. Unlike native array-based queues that suffer from O(n) shifting, this package maintains constant-time operations even with millions of elements. It ships TypeScript definitions, supports both CommonJS and ES Modules, and offers a simple API: enqueue, dequeue, peek, clear, size, and isEmpty. The default internal array size is 4096, but can be configured. Suitable for Node.js and browser environments. Stable release, no recent updates.
npm install elegant-queueNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage: creating a Queue, enqueue, dequeue, peek, size, isEmpty, and clear.
Check queue.isEmpty() before calling dequeue(), or wrap in try-catch.
Use isEmpty() before peek, or catch the exception.
When passing a single argument, if it's a number it sets buffer size; if it's an array it initializes the queue. Do not mix types.
N/A
Always call isEmpty() before dequeue/peek, or catch the exception.
Use import { Queue } from 'elegant-queue' instead of import Queue from 'elegant-queue'.Run 'npm install elegant-queue' and ensure 'node_modules' is included in TypeScript resolution.
No dependency data recorded yet.