Registry / database / queue-list

queue-list

JSON →
library1.1.8jsnpmunverified

A lightweight JavaScript queue data structure with O(1) time complexity for all operations. Version 1.1.8, stable. Provides a simple, minimal API (enqueue, dequeue, peek, isEmpty, size, clear) and custom console.log formatting for Queue instances. Unlike many other queue implementations that use arrays (O(n) dequeue), this library uses a linked-list-based approach for guaranteed constant-time performance. Suitable for both Node.js and browser environments. No dependencies.

npm install queue-list
INSTALL
IMPORT
SIG · QUEUE-LIST
Q
queue-list
databasejavascriptv1.1.8
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 'queue-list'
const Queue = require('queue-list')
Default ESM export. Not available as named export; using require() works in Node.js CJS only if the package supports it (check your Node version).
Queue (type)
import type Queue from 'queue-list'
TypeScript users should use import type for type-only imports. The package does not ship .d.ts files, so you may need to create your own declaration.
Queue
const { default: Queue } = await import('queue-list')
const Queue = await import('queue-list')
Dynamic import returns an object with a default property. Using const Queue = await import('queue-list') will set Queue to the module object, not the class.

Demonstrates creating a Queue, enqueuing multiple elements, peeking, dequeuing, and clearing, with all O(1) operations.

import Queue from 'queue-list'; const queue = new Queue(); console.log(queue.isEmpty()); // true queue.enqueue('first').enqueue('second').enqueue('third'); console.log(queue.size()); // 3 const front = queue.peek(); console.log(front); // 'first' const removed = queue.dequeue(); console.log(removed); // 'first' console.log(queue.size()); // 2 queue.clear(); console.log(queue.isEmpty()); // true
Debug
Known issues
gotchaconsole.log on a Queue instance may output the internal linked list structure, not a readable queue representation.
fix
Use queue.toArray() if available, or iterate manually. The README mentions custom console.log formatting but it may not work as expected in all environments.
affects: <1.2.0
deprecatedNo deprecated features documented.
affects: all
gotchaThe package does not include TypeScript type definitions. Using it in TypeScript requires manual declaration or @types/queue-list.
fix
Create a global .d.ts file: declare module 'queue-list' { export default class Queue<T = any> { ... } }
affects: all
gotchaenqueue returns the queue instance for chaining, but if you forget to capture the return value, the queue is still mutated.
fix
Chain enqueue calls: queue.enqueue(1).enqueue(2); or assign: const q = queue.enqueue(1);
affects: all
Errors
Common errors & fixes
TypeError: queue_list_1.default is not a constructor
Using a named import instead of default import in CommonJS with transpilation.
fix
Use `const Queue = require('queue-list').default;` or `import Queue from 'queue-list';` in an ESM environment.
Cannot read properties of undefined (reading 'enqueue')
Queue instance not initialized or variable is undefined.
fix
Ensure you create an instance: `const queue = new Queue();` then call queue.enqueue().
queue.dequeue is not a function
Using a plain object instead of a Queue instance, or importing incorrectly.
fix
Check that you imported Queue as a class and created an instance. Use `const queue = new Queue();`.
Upgrade
Version history
1.1.8latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
12
Amazon
1
Resources
queue-list — npm install queue-list · libregistry