Registry / devops / array-async-queue

array-async-queue

JSON →
library1.0.7jsnpmunverified

A lightweight Node.js library (v1.0.7, last updated 2019) for iterating over arrays with controlled concurrency and an optional stop mechanism. Unlike generic async queue libraries, it focuses solely on array processing with a fixed concurrency limit. Requires Node >=5.0.0. Infrequently updated; stable for basic use cases.

npm install array-async-queue
INSTALL
IMPORT
SIG · ARRAY-ASYNC-QUEUE
A
array-async-queue
devopsjavascriptv1.0.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.

arrayAsyncQueue (default)
const arrayAsyncQueue = require('array-async-queue');
import arrayAsyncQueue from 'array-async-queue';
This package uses CommonJS and does not provide an ESM export. Default import via ESM will not work without a bundler or Node's --experimental-require-module.
arrayAsyncQueueType (type)
type ArrayAsyncQueueCallback = (val: any, stop: () => void) => void | Promise<void>; type ArrayAsyncQueue = (arr: any[], concurrency: number, callback: ArrayAsyncQueueCallback) => Promise<void>;
import { arrayAsyncQueue } from 'array-async-queue';
No TypeScript types are shipped; declare manually or use @types/array-async-queue (nonexistent).

Processes an array of numbers with a concurrency limit of 5, logging each item after a 100ms delay.

const arrayAsyncQueue = require('array-async-queue'); const arr = Array.from({ length: 10 }, (_, i) => i); const concurrency = 5; async function process() { await arrayAsyncQueue(arr, concurrency, (val, stop) => { console.log(`Processing ${val}`); return new Promise(resolve => setTimeout(resolve, 100)); }); console.log('All done'); } process().catch(console.error);
Debug
Known issues
gotchaThe callback must return a Promise or undefined; if a promise is returned, the queue waits for it. If the callback returns non-Promise (e.g., null), the queue treats it as immediate resolution.
fix
Always return a Promise if you need async behavior, or return undefined for sync functions.
affects: >=1.0.0
breakingThe package uses synchronous iteration internally; if an element is added to the array during processing, it will not be processed because the queue operates on the original array copy.
fix
Do not mutate the array during processing. Use a separate queue structure if dynamic addition is needed.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: arrayAsyncQueue is not a function
Default export is not a function; the package exports a function directly.
fix
Use `const arrayAsyncQueue = require('array-async-queue');` (correct) or `import * as aa from 'array-async-queue'; aa.default(...)` if using TypeScript with esModuleInterop.
Callback must be a function
Second argument (callback) is not a function, or first argument is not an array.
fix
Ensure first argument is an Array and third argument is a function: `arrayAsyncQueue([1,2,3], 2, (val) => console.log(val))`
Upgrade
Version history
1.0.7latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
15 hits · last 30 days
node
14
OpenAI (training)
1
Resources
array-async-queue — npm install array-async-queue · libregistry