P-Queue is a JavaScript promise queue for controlling how asynchronous and synchronous tasks are scheduled and executed. It is especially useful when applications must limit concurrent operations or respect external API rate limits. Developers can specify how many tasks may run simultaneously and how many may start within a defined time interval. Queued jobs can receive priorities, identifiers, timeouts, and AbortSignal-based cancellation support. The library exposes events and state information for monitoring active, pending, completed, rate-limited, empty, and idle queue conditions. Backpressure helpers can prevent producers from overwhelming the queue when work arrives faster than it can be processed. Custom queue implementations can also replace the default priority scheduler for specialized scheduling behavior.
Features
- Configurable concurrency limits
- Interval-based rate limiting
- Task priorities and identifiers
- Timeout and cancellation support
- Queue events and lifecycle monitoring
- Backpressure and custom scheduling support