Registry / storage / light-queue

light-queue

JSON →
library1.0.0jsnpmunverified

light-queue 1.0.0 is a zero-dependency, lightweight FIFO queue for Node.js and browsers. Released as stable 1.0.0, it offers a simple API with push, pop, drain, isEmpty, and size methods. Unlike more complex queue libraries, it focuses on minimal overhead and ease of use for throttling, retries, and basic queue management. It is actively maintained and suitable for both small and moderate-scale queuing needs.

npm install light-queue
INSTALL
IMPORT
SIG · LIGHT-QUEUE
L
light-queue
storagejavascriptv1.0.0
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('light-queue');
import Queue from 'light-queue';
This package is CJS-only; ESM import will fail.
Queue with arguments
const queue = Queue(['a','b']);
const queue = new Queue(['a','b']);
Queue is a factory function, not a class; 'new' is not required and may cause confusion.
Queue return value
const queue = Queue();
const queue = new Queue();
Same as above; do not use 'new'.

Demonstrates basic FIFO operations: push, pop (single and multiple), drain, and isEmpty.

const Queue = require('light-queue'); const queue = Queue(); queue.push('first'); queue.push('second'); const item = queue.pop(); console.log(item); // 'first' queue.push('third'); const items = queue.pop(2); console.log(items.join(',')); // 'second,third' const all = queue.drain(); console.log(all); // [] console.log(queue.isEmpty()); // true
Debug
Known issues
gotchaQueue is not a constructor; calling 'new Queue()' will not throw but may lead to unexpected behavior.
fix
Use Queue() as a factory function without 'new'.
affects: >=1.0
gotchapop() with no arguments returns a single item, not an array; pop(n) returns an array of n items.
fix
Always check the return type when calling pop() without arguments vs with an argument.
affects: >=1.0
gotchaQueue does not provide event emitters or asynchronous methods; it is purely synchronous.
fix
Use with callbacks or loops for async processing.
affects: >=1.0
Errors
Common errors & fixes
TypeError: Queue is not a constructor
Using 'new Queue()' when Queue is a factory function.
fix
Replace 'new Queue()' with 'Queue()'.
TypeError: queue.pop is not a function
Importing as default with ES6 import (e.g., import Queue from 'light-queue') in an ESM context.
fix
Use require('light-queue') or try import * as Queue from 'light-queue'.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
24 hits · last 30 days
node
20
Amazon
1
OpenAI (training)
1
Resources
light-queue — npm install light-queue · libregistry