Registry / devops / async-function-queue

async-function-queue

JSON →
library1.0.0jsnpmunverified

Simple async function queue with configurable concurrency. Current stable version is 1.0.0. Maintained by yld.io. No significant release cadence. Key differentiators: minimal API, CommonJS only, callback-based, event-driven (entry, exit, drain events). Suitable for limiting concurrency of async operations.

npm install async-function-queue
INSTALL
IMPORT
SIG · ASYNC-FUNCTION-QUE
A
async-function-queue
devopsjavascriptv1.0.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.

Queue
var Queue = require('async-function-queue');
import Queue from 'async-function-queue';
This package is CommonJS only, does not support ES modules.
queue instance
var queue = Queue(concurrency);
var queue = new Queue(concurrency);
Queue is a factory function, not a constructor. Do not use 'new'.
queue.push
queue.push(function(cb) { ... });
queue.push(async function() { ... });
Pushed functions must accept a callback as the sole argument. Async functions with no callback parameter will not work.

Creates a queue with concurrency 2, pushes 5 tasks, and logs drain event when all complete.

var Queue = require('async-function-queue'); var concurrency = 2; var queue = Queue(concurrency); var tasks = [1,2,3,4,5]; tasks.forEach(function(task) { queue.push(function(cb) { console.log('processing task', task); setTimeout(cb, 100); }); }); queue.on('drain', function() { console.log('all tasks done'); });
Debug
Known issues
gotchaDo not use 'new' with Queue; it is a factory function.
fix
Call Queue(concurrency) without new.
affects: >=1.0
gotchaPushed functions must accept a callback and call it when done. Async functions without callback parameter will hang the queue.
fix
Ensure each function calls the callback when work is complete.
affects: >=1.0
deprecatedThis package is not actively maintained; last release was long ago. Consider alternatives like async.queue or p-queue.
fix
Migrate to modern queue libraries such as 'p-queue' or 'async.queue'.
affects: >=0.0
gotchaNo TypeScript types provided; library is JavaScript only.
fix
Import with require('async-function-queue') and handle typings separately.
affects: >=1.0
Errors
Common errors & fixes
TypeError: Queue is not a constructor
Using 'new Queue()' instead of 'Queue()'.
fix
Use Queue(concurrency) without 'new'.
Error: queue.push is not a function
CommonJS require returns a function that returns the queue instance; push is on that instance.
fix
Ensure you call Queue(concurrency) to get a queue object, then call .push on it.
Queue never drains / tasks not executing
Pushed functions do not call the callback parameter.
fix
Make sure each pushed function accepts a callback argument and calls it when done.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
8
OpenAI (training)
2
Resources
async-function-queue — npm install async-function-queue · libregistry