Registry / storage / async-iterable-queue

async-iterable-queue

JSON →
library1.0.16jsnpmunverified

A lightweight TypeScript library providing an AsyncIterableQueue<T> class that implements both AsyncIterable<T> and async push/end methods. Version 1.0.16, released as needed with no fixed cadence. It allows producers to push items and consumers to iterate asynchronously using for-await-of. Unlike other async queue libraries, it integrates directly with JavaScript's async iteration protocol, supports TypeScript, and has zero dependencies. It requires Node.js >=14.17.5 and is ESM-only.

npm install async-iterable-queue
INSTALL
IMPORT
SIG · ASYNC-ITERABLE-QUE
A
async-iterable-queue
storagejavascriptv1.0.16
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.

AsyncIterableQueue
import { AsyncIterableQueue } from 'async-iterable-queue'
const { AsyncIterableQueue } = require('async-iterable-queue')
Package is ESM-only; CommonJS require() will throw.
default import
import AsyncIterableQueue from 'async-iterable-queue'
The package does not export a default.
Only named export exists.
type import
import type { AsyncIterableQueue } from 'async-iterable-queue'
Using value import for type-only contexts.
Use type import when only using as a type to avoid bundling issues.

Creates an AsyncIterableQueue, pushes two items, ends the queue, and consumes them with for-await-of.

import { AsyncIterableQueue } from 'async-iterable-queue'; async function main() { const queue = new AsyncIterableQueue<string>(); // Producer setTimeout(() => { queue.push('hello'); queue.push('world'); queue.end(); }, 100); // Consumer for await (const item of queue) { console.log(item); } } main().catch(console.error);
Debug
Known issues
breakingESM-only: package does not support CommonJS require().
fix
Use import statements and ensure your project is configured for ESM (e.g., 'type': 'module' in package.json).
affects: >=1.0.0
gotchaQueue must be consumed after end() is called or push() will reject.
fix
Ensure you call end() only after all pushes are complete, and handle rejection on push.
affects: >=1.0.0
gotchaCalling push() after end() will throw an error.
fix
Always check if queue has ended before pushing, or catch errors.
affects: >=1.0.0
breakingThe package name is 'async-iterable-queue' not 'async-iterable-queue' (no typo).
fix
Install with 'npm i async-iterable-queue' (s with 'async' not 'asyn').
affects: all
Errors
Common errors & fixes
SyntaxError: Cannot use import statement outside a module
Running ESM code in a CommonJS project.
fix
Add 'type': 'module' to your package.json or use .mjs extension.
TypeError: Class constructor AsyncIterableQueue cannot be invoked without 'new'
Forgetting the 'new' keyword when instantiating.
fix
Use new AsyncIterableQueue<T>() to create an instance.
TypeError: queue.push is not a function
Attempting to use a default import instead of named import.
fix
Use import { AsyncIterableQueue } from 'async-iterable-queue'.
Upgrade
Version history
1.0.16latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
46 hits · last 30 days
node
40
Resources
async-iterable-queue — npm install async-iterable-queue · libregistry