A lightweight queue that ensures a given asynchronous function (load) is executed only once for a given set of parameters, while multiple callers can await the result. Version 1.2.1 is the latest stable release. The package is minimal (zero dependencies) and designed for Node.js 4+. It provides an EventEmitter-based API and custom key serialization via stringify. Use cases include deduplicating API calls, database queries, or any expensive async operation. Unlike similar deduplication utilities, pending-queue queues listeners rather than memoizing results, making it suitable for one-shot or short-lived caching.
npm install pending-queueNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates deduplication: three calls to .add(1,2) share a single execution of the load function.
Provide a custom stringify function or use addWithKey with an explicit key.
Ensure load always settles or implement a timeout externally.
Use addWithKey with a safe key string.
Replace `import Queue from 'pending-queue'` with `const Queue = require('pending-queue')`.Instantiate with `new Queue({ load: ... })` then call `.add()`.Attach a .catch() to each .add() call or use the 'error' event on the queue.
No dependency data recorded yet.