Registry / testing / it-queue

it-queue

JSON →
library1.1.3jsnpmunverified

it-queue (v1.1.3) is an async queue implementation built on top of p-queue, providing the ability to iterate over queue results using async generators. It ships TypeScript types and follows the 'it' family of packages focused on async iteration patterns. Key differentiators: aborting a task removes it from the queue, and results can be consumed via `for await...of` or `it-all`. Compared to p-queue, it-queue gives direct access to the underlying queue and supports iteration over completed items. The package is part of the libp2p/achingbrain ecosystem and is actively maintained.

npm install it-queue
INSTALL
IMPORT
SIG · IT-QUEUE
I
it-queue
testingjavascriptv1.1.3
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
import { Queue } from 'it-queue'
import Queue from 'it-queue'
Named export only; no default export.
Queue (CommonJS)
const { Queue } = require('it-queue')
const Queue = require('it-queue')
Must destructure because Queue is a named export.
Queue type (TypeScript)
import type { Queue } from 'it-queue'
Use type-only import for improved compile-time performance.

Creates a queue with concurrency 2, adds three async tasks, and iterates over results using it-all.

import { Queue } from 'it-queue' import all from 'it-all' const queue = new Queue({ concurrency: 2 }) queue.add(async () => { await new Promise(resolve => setTimeout(resolve, 100)) return 'first' }) queue.add(async () => { return 'second' }) queue.add(async () => { return 'third' }) // Wait for all results const results = await all(queue) console.log(results) // ['first', 'second', 'third'] console.log(queue.size) // 0 (all completed) console.log(queue.running) // 0 console.log(queue.queued) // 0
Debug
Known issues
gotchaThe queue must be consumed via iteration (e.g., `for await...of` or `it-all`) to drain tasks; otherwise, they will never run.
fix
Always iterate over the queue instance to process tasks. If you don't need the results, consider using a different queue library.
affects: >=1.0.0
gotchaAborting a task removes it from the queue, but the abort signal must be passed in the task options.
fix
Pass `signal` as part of the second argument to `add()`: `queue.add(task, { signal })`.
affects: >=1.0.0
deprecatedThe `queue.abort()` method is deprecated since v1.1.0 in favor of per-task abort signals.
fix
Use `AbortController` and pass `signal` to individual tasks instead of calling `queue.abort()`.
affects: >=1.1.0
Errors
Common errors & fixes
TypeError: queue is not iterable
Using `for (const result of queue)` without async iteration (the queue is an async iterable).
fix
Use `for await (const result of queue)` or `await all(queue)`.
Cannot read properties of undefined (reading 'Symbol(asyncIterator)')
Forgetting to consume the queue; no tasks will start processing until you iterate.
fix
Start iterating over the queue (e.g., `for await...of queue`) immediately after adding tasks.
Error: The task was aborted
A task was aborted via its signal, which is expected behavior but may be confusing.
fix
Handle the abort error in your task or catch it when iterating.
Upgrade
Version history
1.1.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
it-queue — npm install it-queue · libregistry