Registry / devops / then-queue

then-queue

JSON →
library1.3.0jsnpmunverified

A simple promise-based asynchronous queue for Node.js, version 1.3.0. It provides a basic FIFO queue with push and pop methods, where pop returns a promise that resolves when an item is available. The queue length can be negative if pop is called more times than push, which may be surprising. It uses an event-driven approach (length-changed event) for managing workers. Since it is lightweight and minimal, it suits simple async workflows where a full-featured library like async.queue or bull is overkill. The package has no dependencies and is small, but is in maintenance mode with no recent updates since 2015. It does not support backpressure, concurrency limits, or persistence.

devopstesting
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.

This is a CommonJS package; ESM import is not supported without a wrapper. Use require().

var Queue = require('then-queue'); var q = new Queue();

Queue must be instantiated with new; calling Queue() without new will cause a TypeError.

var Queue = require('then-queue'); var q = new Queue();

push does not accept a callback; it returns nothing. Items are simply added.

q.push(item)

pop returns a Promise; do not pass a callback. Use .then() or await.

q.pop().then(function(item) { ... })

length can be negative if pop is called more times than push.

var len = q.length;

Demonstrates creating a queue, pushing items, popping them asynchronously, and listening to the length-changed event.

var Queue = require('then-queue'); var q = new Queue(); // Push some items q.push('first'); q.push('second'); // Pop items in order q.pop().then(function(item) { console.log(item); // 'first' }); q.pop().then(function(item) { console.log(item); // 'second' }); // Listen for length changes q.on('length-changed', function() { console.log('Queue length:', q.length); }); // Push another triggers event q.push('third');
Debug
Known footguns
gotchaqueue.length can be negative if pop() is called more than push() before promises resolve
gotchaqueue.pop() returns a promise that may never resolve if no item is pushed
deprecatedThe package is no longer actively maintained; last update in 2015
gotchaQueue constructor must be called with `new`; otherwise it throws TypeError
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
9 hits · last 30 days
gptbot
3
mj12bot
1
Resources