Registry / devops / ts-async-queue

ts-async-queue

JSON →
library1.1.0jsnpmunverified

A simple async-await task queue written in TypeScript, version 1.1.0. It provides a TaskQueue class with start, pause, resume, and stop methods for managing sequential async task execution. Unlike complex libraries with concurrency or priority management, this focuses on simplicity and minimalism with a 2KB minified bundle. It ships TypeScript types and supports multiple module formats (es5, es6, esnext, iife, umd). Dependencies: none. Release cadence: low.

npm install ts-async-queue
INSTALL
IMPORT
SIG · TS-ASYNC-QUEUE
T
ts-async-queue
devopsjavascriptv1.1.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.

TaskQueue
import { TaskQueue } from 'ts-async-queue'
import TaskQueue from 'ts-async-queue'
It is a named export, not default.
QueueError
import { QueueError } from 'ts-async-queue'
const QueueError = require('ts-async-queue').QueueError
Both CJS and ESM work, but named import is idiomatic for ESM.
TaskQueue (CJS)
const { TaskQueue } = require('ts-async-queue')
const TaskQueue = require('ts-async-queue')
CommonJS users must destructure the named exports.

Demonstrates creating a TaskQueue, enqueuing a task, starting the queue, and listening for the 'done' event.

import { TaskQueue, QueueError } from 'ts-async-queue'; const queue = new TaskQueue(); const task1 = () => new Promise<string>(resolve => setTimeout(() => resolve('done'), 100)); queue.enqueue(task1); queue.start(); // After ~100ms, task1 completes and queue emits 'done' event queue.on('done', (result: string) => console.log(result));
Debug
Known issues
gotchaQueue does not handle concurrency; tasks are executed sequentially. If you need parallel execution, look elsewhere.
fix
Use a library like p-queue or async.queue for concurrency.
affects: >=1.0.0
gotchaThe 'pause()' method does NOT stop the currently executing task; it only prevents subsequent tasks from starting. If you need immediate halt, use 'stop()'.
fix
Use stop() to cancel pending tasks and reject the current task's promise.
affects: >=1.0.0
deprecatedThe 'clear()' method removes all pending tasks but does not affect the currently running task. Its behavior may change in future versions.
fix
Consider using 'stop()' followed by emptying the queue manually.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: queue is not iterable
Trying to spread or iterate over the queue instance directly.
fix
Use queue.tasks property to access the internal array: [...queue.tasks]
QueueError: Cannot enqueue while queue is running
Attempting to add tasks to the queue while it is currently started and not paused.
fix
Pause or stop the queue before enqueuing new tasks.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources