async
3.2.6 · 19 Aug 2024MIT149.5M / weekRepositoryHomepagenpmAtom feed
3.2.6 is the newest release of 3.x.
In short
9 breaking4 new1 fixed3 changed
- Breaking
There are a lot of new features and subtle breaking changes in this major version, but the biggest feature is that most Async methods return a Promise if you omit the callback, meaning you can
awaitthem from within anasyncfunction. - Breaking
Most Async methods return a Promise when the final callback is omitted, making them
await-able! - Breaking
We are now making heavy use of ES2015 features, this means we have dropped out-of-the-box support for Node 4 and earlier, and many old versions of browsers. (#1541, #1553)
- Breaking
In
queue,priorityQueue,cargoandcargoQueue, the "event"-style methods, likeq.drainandq.saturatedare now methods that register a callback, rather than properties you assign a callback to. They are now of the formq.drain(callback). If you do not pass a callback a Promise will be returned for the next occurrence of the event, making themawait-able, e.g.await q.drain(). (#1586, #1641) - Breaking
Calling
callback(false)will cancel an async method, preventing further iteration and callback calls. This is useful for preventing memory leaks when you break out of an async flow by calling an outer callback. (#1064, #1542) - Breaking
duringanddoDuringhave been removed, and insteadwhilst,doWhilst,untilanddoUntilnow have asynchronoustestfunctions. (#850, #1557) - Breaking
limitsof less than 1 now cause an error to be thrown in queues and collection methods. (#1249, #1552) - Breaking
memoizeno longer memoizes errors (#1465, #1466)
Security
1 advisory affects 3.0.0; 3.2.2 fixes them
- HighPrototype Pollution in asyncGHSA-fwr7-v2mv-hh25 · 7 Apr 2022Fixed in 3.2.2
Release note
The async/await release!
There are a lot of new features and subtle breaking changes in this major version, but the biggest feature is that most Async methods return a Promise if you omit the callback, meaning you can await them from within an async function.
const results = await async.mapLimit(urls, 5, async url => {
const resp = await fetch(url)
return resp.body
})Breaking Changes
- Breaking
Most Async methods return a Promise when the final callback is omitted, making them
await-able! - Breaking
We are now making heavy use of ES2015 features, this means we have dropped out-of-the-box support for Node 4 and earlier, and many old versions of browsers. (#1541, #1553)
- Breaking
In
queue,priorityQueue,cargoandcargoQueue, the "event"-style methods, likeq.drainandq.saturatedare now methods that register a callback, rather than properties you assign a callback to. They are now of the formq.drain(callback). If you do not pass a callback a Promise will be returned for the next occurrence of the event, making themawait-able, e.g.await q.drain(). (#1586, #1641) - Breaking
Calling
callback(false)will cancel an async method, preventing further iteration and callback calls. This is useful for preventing memory leaks when you break out of an async flow by calling an outer callback. (#1064, #1542) - Breaking
duringanddoDuringhave been removed, and insteadwhilst,doWhilst,untilanddoUntilnow have asynchronoustestfunctions. (#850, #1557) - Breaking
limitsof less than 1 now cause an error to be thrown in queues and collection methods. (#1249, #1552) - Breaking
- Breaking
applyEach/applyEachSerieshave a simpler interface, to make them more easily type-able. It always returns a function that takes in a single callback argument. If that callback is omitted, a promise is returned, making it awaitable. (#1228, #1640)
New Features
Async generators are now supported in all the Collection methods.
Added
cargoQueue, a queue with bothconcurrencyandpayloadsize parameters.Queue objects returned from
queuenow have aSymbol.iteratormethod, meaning they can be iterated over to inspect the current list of items in the queue. (#1459, #1556)A ESM-flavored
async.mjsis included in theasyncpackage. This is described in thepackage.json"module"field, meaning it should be automatically used by Webpack and other compatible bundlers.
Bug fixes
Other
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.