Skip to content

Releases: rxaviers/async-pool

v2.1.0

10 May 11:22
Compare
Choose a tag to compare

⭐️ Enhancement

  • Improve the promise consumption logic #44

🐛 Fixes

  • Consume all promises, even if they are fullfilled within the same tick #42

v2.0.1

20 Mar 12:37
Compare
Choose a tag to compare

🐛 Fixes

⚙️ Chore

  • Fix eslint script #37

v2.0.0

18 Mar 13:06
Compare
Choose a tag to compare

🌟 New API (breaking change)

Support for await...of usage by returning an async iterator.

const timeout = ms => new Promise(resolve => setTimeout(() => resolve(ms), ms));

for await (const ms of asyncPool(2, [1000, 5000, 3000, 2000], timeout)) {
  console.log(ms);
}
// Call iterator timeout(1000)
// Call iterator timeout(5000)
// Concurrency limit of 2 reached, wait for the quicker one to complete...
// 1000 finishes
// for await...of outputs "1000"
// Call iterator timeout(3000)
// Concurrency limit of 2 reached, wait for the quicker one to complete...
// 3000 finishes
// for await...of outputs "3000"
// Call iterator timeout(2000)
// Itaration is complete, wait until running ones complete...
// 5000 finishes
// for await...of outputs "5000"
// 2000 finishes
// for await...of outputs "2000"

The main difference: 1.x API waits until all of the promises completes, then all results are returned. The new API (thanks to async iteration) let each result be returned as soon as it completes.

The environment baseline of the new 2.x is ES9 (Node v10). The environment baseline of 1.x is ES6.

v1.3.0

18 Mar 13:00
Compare
Choose a tag to compare

🎉 New Features

  • Support for any iterable, not just array
  • Remove yaassertion dependency

🐛 Fixes

  • Handle unhandled rejection #32