Registry / productivity / sg-queue

sg-queue

JSON →
library1.1.4jsnpmunverified

A minimal Node.js task queue for executing asynchronous functions sequentially. Version 1.1.4. It ensures that tasks are processed one after another in order, returning a promise that resolves when all tasks complete. Suitable for use with generators and promises. No external dependencies. Supports Node.js >=6.

npm install sg-queue
INSTALL
IMPORT
SIG · SG-QUEUE
S
sg-queue
productivityjavascriptv1.1.4
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.

sgQueue
const sgQueue = require('sg-queue')
const sgQueue = require('sg-queue').default
The package uses CommonJS and exports a function directly.
sgQueue
import sgQueue from 'sg-queue'
import { sgQueue } from 'sg-queue'
For ES modules, default import works with Node.js >=12 if using --experimental-modules or esm package.
sgQueue
let queue = sgQueue()
let queue = new sgQueue()
sg-queue is a function, not a constructor. Call it directly without 'new'.

This shows how to create a queue, push tasks, and wait for completion.

const sgQueue = require('sg-queue'); // Create a sequential queue const queue = sgQueue(); // Add tasks queue.push(() => new Promise(resolve => { setTimeout(() => resolve('Task 1 done'), 100); })); queue.push(() => new Promise(resolve => { setTimeout(() => resolve('Task 2 done'), 50); })); // Wait for all tasks to complete queue.then(() => { console.log('All tasks finished'); }).catch(err => console.error(err));
Debug
Known issues
gotchasg-queue does not expose a way to cancel or clear tasks once pushed. Pushed tasks will execute even if the queue promise is ignored.
fix
Design your application to handle queued tasks as fire-and-forget or use a library that supports cancellation.
affects: >=0.0.0
gotchaThe queue does not return results per task; you must chain .then() on each push to collect individual results.
fix
Capture results by appending .then() to the return of queue.push(), as shown in the usage example.
affects: >=0.0.0
deprecatedThe package uses 'require('sg-queue')' with callback-based Node.js patterns and does not support ES modules natively (no 'exports' field in package.json).
fix
For modern Node.js (>=14), consider using a more actively maintained queue library like 'p-queue' or 'async.queue'.
affects: >=0.0.0
gotchaThe queue does not provide concurrency control; all tasks run one at a time sequentially, which may be a bottleneck for I/O-heavy workloads.
fix
If you need concurrency, choose a dedicated async task queue like 'p-queue' (supports concurrency limit).
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: sgQueue is not a constructor
Calling 'new sgQueue()' instead of 'sgQueue()'.
fix
Remove 'new'; just call sgQueue() as a normal function.
Error: Cannot find module 'sg-queue'
Package not installed or not in node_modules.
fix
Run 'npm install sg-queue --save' in your project root.
TypeError: queue.push is not a function
Requiring the module incorrectly or using it after the queue's promise resolves.
fix
Ensure you require the function and call it to create a queue object. queue.push is available before queue.then() resolves.
Upgrade
Version history
1.1.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
12
OpenAI (training)
1
Resources
sg-queue — npm install sg-queue · libregistry