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
✓ const Queue = require('async-parallel-queue');
const queue = new Queue({concurrency: 10});
✗ import Queue from 'async-parallel-queue';
Package is CommonJS only; no named export. Use require() or dynamic import().
Queue
✓ const { default: Queue } = await import('async-parallel-queue');
const queue = new Queue({concurrency: 10});
✗ const Queue = require('async-parallel-queue').default;
For ESM, use dynamic import with .default.
queue.add
✓ queue.add(async () => fetch('https://example.com'));
✗ queue.add(fetch('https://example.com'));
Pass an async function, not a Promise.
queue.fn
✓ const download = queue.fn(async (url) => fetch(url));
✗ const download = queue.fn((url) => fetch(url));
fn expects an async function; wrapping in async ensures proper handling.
Creates a queue with concurrency 3, adds three async tasks with varying delays, and waits for the queue to finish.
const Queue = require('async-parallel-queue');
const queue = new Queue({ concurrency: 3 });
// Simulate async tasks
queue.add(async () => {
await new Promise(resolve => setTimeout(resolve, 100));
console.log('Task 1 done');
});
queue.add(async () => {
await new Promise(resolve => setTimeout(resolve, 50));
console.log('Task 2 done');
});
queue.add(async () => {
await new Promise(resolve => setTimeout(resolve, 200));
console.log('Task 3 done');
});
// Wait for all tasks to complete
await queue.waitIdle();
console.log('All tasks completed');
Errors
Common errors & fixes
TypeError: Queue is not a constructor
Trying to use default import from an ESM context without dynamic import.
fixconst Queue = require('async-parallel-queue'); Error: concurrency must be a positive integer
Passing a non-integer or negative concurrency value to the Queue constructor.
fixnew Queue({ concurrency: 3 }); // integer > 0 UnhandledPromiseRejectionWarning: ...
Task function threw an error and no .catch was attached.
fixqueue.add(async () => { ... }).catch(err => console.error(err)); queue.waitIdle never resolves
New tasks are being added while waiting for idle.
fixStop adding tasks before calling waitIdle, or use a timeout.
Audit
Dependencies
No dependency data recorded yet.