Releases: henrygd/queue
v1.2.0
Features
- Time-based rate limiting: Added
@henrygd/queue/rlexport. You can now limit how many tasks start within a specific time window in addition to concurrency. (#3)
import { newQueue } from '@henrygd/queue/rl'
// 10 concurrent tasks max, but only 3 can start per second
const queue = newQueue(10, 3, 1000)Bug Fixes
- Fix
clear()hanging:clear()now rejects all pending promises with aQueue clearederror. Previously, pending promises were silently removed, causingqueue.all()to hang. (#4)
Full Changelog: v1.1.0...v1.2.0
v1.1.0
v1.0.7
Exports Queue interface to prevent "is using name 'Queue' from external module" TypeScript error
Full Changelog: v1.0.6...v1.0.7
v1.0.6
Performance improvements in V8
Full Changelog: v1.0.5...v1.0.6
v1.0.5
Updates
- Improved performance
Notes
Benchmark tests have been changed so that every library uses the exact same test.
promise-queue and p-limit don't provide a promise that resolves when the queue is empty, so I was using Promise.all with an array of jobs. Which is how you use them in real life. But it's a slight performance hit and I don't want the tests to be different.
The updated results are in the readme.
Full Changelog: v1.0.4...v1.0.5
v1.0.4
Adds CommonJS modules
Full Changelog: v1.0.3...v1.0.4
v1.0.3
No new features or fixes. Just refactoring and adding new benchmarks like this one:
Cloudflare Workers benchmark
| Library | Requests/sec | Total (sec) | Average | Slowest |
|---|---|---|---|---|
| @henrygd/queue | 622.7809 | 1.6057 | 0.0786 | 0.1155 |
| promise-queue | 324.8053 | 3.0788 | 0.1512 | 0.2174 |
| async.queue | 203.9315 | 4.9036 | 0.2408 | 0.3450 |
| fastq | 184.0524 | 5.4332 | 0.2670 | 0.3546 |
| queue | 86.4867 | 11.5625 | 0.5672 | 0.7636 |
| p-limit | 67.5275 | 14.8088 | 0.7274 | 1.0657 |
Full Changelog: v1.0.2...v1.0.3
v1.0.2
queue.donecan now be invoked in different contexts simultaneously- General refactoring. Library is now at 332 bytes :)
- Added
fastqandasync.queueto the benchmark
Full Changelog: v1.0.1...v1.0.2
v1.0.1
Updates
- Add support for AsyncLocalStorage
- Refactor
queue.done()implementation. Bundle now down to 342 bytes. :) - Update benchmarks
Full Changelog: v1.0.0...v1.0.1
v1.0.0
Updates
- add
donemethod which returns a promise that resolves when the queue is empty - add
clearmethod to empty the queue - add
sizemethod to get the total number of promises in the queue - add
activemethod to get the number of promises currently running
Benchmark
Average of five runs passing Promise.resolve() through the same queue one million times on a Ryzen 7 6800H laptop using Bun 1.1.12.
p-limit is used for comparison because it's the most popular comparable library, with 117 million weekly downloads (!) as of June 2024. I've used it before and it's great.
Also included is the minified bundle size (no gzip) for reference.
| Library | Version | Time (ms) | Heap size (MB) | Bundle size (B) |
|---|---|---|---|---|
| @henrygd/queue | 1.0.0 | 512 | 37.4 | 352 |
| p-limit | 5.0.0 | 2,276 | 223.3 | 1,763 |
Full Changelog: v0.0.2...v1.0.0
