Registry / devops / simple-promise-queue

simple-promise-queue

JSON →
library0.1.7jsnpmunverified

A lightweight, promise-based queue built on top of the queue package, allowing users to push functions that resolve or reject and get a promise representing the task. Version 0.1.7 is the latest, with no active development. It supports concurrency control and automatic start. Compared to similar libraries, it provides a simple API with pushTask and unshiftTask, and inherits additional methods from the queue package. The library is ESM and CJS compatible, but does not include TypeScript typings.

npm install simple-promise-queue
INSTALL
IMPORT
SIG · SIMPLE-PROMISE-QUE
S
simple-promise-queue
devopsjavascriptv0.1.7
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.

default (Queue)
import Queue from 'simple-promise-queue'
const Queue = require('simple-promise-queue')
CommonJS require works. For TypeScript, you may need to use esModuleInterop.
setPromise
import Queue from 'simple-promise-queue'; Queue.setPromise(bluebird);
import { setPromise } from 'simple-promise-queue'
setPromise is a static method on the Queue constructor, not a named export.
Queue constructor
const queue = new Queue({ concurrency: 5 })
const queue = new queue()
Instantiate with `new Queue(options)`, not lowercase.

Creates a queue with concurrency 2, pushes two tasks, and waits for both to complete.

import Queue from 'simple-promise-queue'; const queue = new Queue({ autoStart: true, concurrency: 2 }); const task1 = queue.pushTask((resolve, reject) => { setTimeout(() => resolve('Task 1 done'), 1000); }); const task2 = queue.pushTask((resolve, reject) => { setTimeout(() => resolve('Task 2 done'), 500); }); Promise.all([task1, task2]).then(results => { console.log(results); // ['Task 1 done', 'Task 2 done'] });
Debug
Known issues
gotchaQueue does not start automatically unless autoStart option is set to true.
fix
Pass { autoStart: true } to the constructor, or call queue.start() after pushing tasks.
affects: >=0.0.0
gotchaThe pushTask callback must call resolve or reject; otherwise the promise never settles.
fix
Ensure callback invokes resolve(value) or reject(error).
affects: >=0.0.0
gotchaThe queue inherits from the 'queue' package but does not re-export its methods; you must access them via the queue instance.
fix
Use queue methods like queue.start(), queue.stop(), etc., as documented in the parent package.
affects: >=0.0.0
deprecatedNo TypeScript typings are provided; users must create custom type declarations.
fix
Create a .d.ts file: declare module 'simple-promise-queue' { ... }
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: queue.pushTask is not a function
Queue is not instantiated correctly; pushTask is an instance method.
fix
Create an instance: const queue = new Queue(); queue.pushTask(...)
Cannot find module 'simple-promise-queue'
Package not installed or import path incorrect.
fix
Run npm install simple-promise-queue and ensure correct import syntax.
Task never resolves
Callback does not call resolve() or reject().
fix
Ensure callback calls resolve(value) or reject(error).
Upgrade
Version history
0.1.7latest on npm
Audit
Dependencies
queuerequiredCore dependency; simple-promise-queue inherits from the queue package.
Agent activity
9 hits · last 30 days
node
8
Resources
simple-promise-queue — npm install simple-promise-queue · libregistry