async
3.2.6 · 19 Aug 2024MIT149.5M / weekRepositoryHomepagenpmAtom feed
86 stable releases, newest first, by release line. Notes are quoted as the maintainers published them.
- 3.x · latest line
3.2.6
19 Aug 2024- Security
Fix ReDoS vulnerability in
autoInject
3.2.5
3 Nov 2023Ensure
Errorobjects such asAggregateErrorare propagated without modification
3.2.4
7 Jun 2022Fix a bug in
priorityQueuewhere it didn't wait for the result.Fix a bug where
unshiftAsyncwas included inpriorityQueue.
3.2.2
28 Oct 2021- Security
Fix potential prototype pollution exploit
3.2.1
5 Aug 2021Use
queueMicrotaskif available to the environmentMinor perf improvement in
priorityQueueMore examples in documentation
3.1.1
24 Jan 2020Allow redefining
nameproperty on wrapped functions.
3.1.0
23 Jun 2019Added
q.pushAsyncandq.unshiftAsync, analagous toq.pushandq.unshift, except they always do not accept a callback, and reject if processing the task errors.Promises returned from
q.pushandq.unshiftwhen a callback is not passed now resolve even if an error ocurred.Fixed a parsing bug in
autoInjectwith complicated function bodies
Added
q.pushAsyncandq.unshiftAsync, analagous toq.pushandq.unshift, except they always do not accept a callback, and reject if processing the task errors.Promises returned from
q.pushandq.unshiftwhen a callback is not passed now resolve even if an error ocurred.Fixed a parsing bug in
autoInjectwith complicated function bodiesAdded ES6+ configuration for Browserify bundlers
3.0.1
26 May 2019Fixed a regression where arrays passed to
queueandcargowould be completely flattened.Clarified Async's browser support
3.0.0
20 May 2019- Breaking
Most Async methods return a Promise when the final callback is omitted, making them
await-able! - 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)
The
async/awaitrelease!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.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
- 2.x
2.6.1
21 May 2018Made
async-esmore optimized for webpack usersFixed a stack overflow with large collections and a synchronous iterator
2.6.0
7 Nov 2017Added missing aliases for many methods. Previously, you could not (e.g.)
require('async/find')or useasync.anyLimit.
2.5.0
25 Jun 2017Added
concatLimit, theLimitequivalent ofconcat(#1426, #1430)concatimprovements: it now preserves order, handles falsy values and theiterateecallback takes a variable number of arguments (#1437, #1436)Fixed an issue in
queuewhere there was a size discrepancy betweenworkersList().lengthandrunning()(#1428, #1429)
2.4.0
29 Apr 2017Improved performance, most notably in
parallelandwaterfall
Added
tryEach, for running async functions in parallel, where you only expect one to succeed. (#1365, #687)Improved performance, most notably in
parallelandwaterfallAdded
queue.remove(), for removing items in aqueue(#1397, #1391)Fixed using
eval, preventing Async from running in pages with Content Security Policy (#1404, #1403)Fixed errors thrown in an
asyncifyed function's callback being caught by the underlying PromiseFixed timing of
queue.empty()
2.3.0
2 Apr 2017Added support for ES2017
asyncfunctions. Wherever you can pass a Node-style/CPS function that uses a callback, you can also pass anasyncfunction. Previously, you had to wrapasyncfunctions withasyncify. The caveat is that it will only work ifasyncfunctions are supported natively in your environment, transpiled implementations can't be detected. (#1386, #1390)
2.1.5
19 Feb 2017Fix
autobug when function names collided with Array.prototypeImprove some error messages
Avoid stack overflow case in queue
Fix
autobug when function names collided with Array.prototypeImprove some error messages
Avoid stack overflow case in queue
Fixed an issue in
some,everyandfindwhere processing would continue after the result was determined.Cleanup implementations of
some,everyandfind
2.1.4
22 Nov 20162.1.1
12 Oct 20162.0.0
13 Jul 2016Lots of changes here!
First and foremost, we have a slick new site for docs. Special thanks to @hargasinski for his work converting our old docs to
jsdocformat and implementing the new website. Also huge ups to @ivanseidel for designing our new logo. It was a long process for both of these tasks, but I think these changes turned out extraordinary well.The biggest feature is modularization. You can now
require("async/series")to only require theseriesfunction. Every Async library function is available this way. You still canrequire("async")to require the entire library, like you could do before.We also provide Async as a collection of ES2015 modules. You can now
import {each} from 'async-es'orimport waterfall from 'async-es/waterfall'. If you are using only a few Async functions, and are using a ES bundler such as Rollup, this can significantly lower your build size.Major thanks to @Kikobeats, @aearly and @megawac for doing the majority of the modularization work, as well as @jdalton and @Rich-Harris for advisory work on the general modularization strategy.
Another one of the general themes of the 2.0 release is standardization of what an "async" function is. We are now more strictly following the node-style continuation passing style. That is, an async function is a function that:
Takes a variable number of arguments
The last argument is always a callback
The callback can accept any number of arguments
The first argument passed to the callback will be treated as an error result, if the argument is truthy
Any number of result arguments can be passed after the "error" argument
The callback is called once and exactly once, either on the same tick or later tick of the JavaScript event loop.
There were several cases where Async accepted some functions that did not strictly have these properties, most notably
auto,every,some, andfilter.Another theme is performance. We have eliminated internal deferrals in all cases where they make sense. For example, in
waterfallandauto, there was asetImmediatebetween each task -- these deferrals have been removed. AsetImmediatecall can add up to 1ms of delay. This might not seem like a lot, but it can add up if you are using many Async functions in the course of processing a HTTP request, for example. Nearly all asynchronous functions that do I/O already have some sort of deferral built in, so the extra deferral is unnecessary. The trade-off of this change is removing our built-in stack-overflow defense. Many synchronous callback calls in series can quickly overflow the JS call stack. If you do have a function that is sometimes synchronous (calling its callback on the same tick), and are running into stack overflows, wrap it withasync.ensureAsync().Another big performance win has been re-implementing
queue,cargo, andpriorityQueuewith doubly linked lists instead of arrays. This has lead to queues being an order of magnitude faster on large sets of tasks.New Features
Async is now modularized. Individual functions can be
require()d from the main package. (require('async/auto')) (#984, #996)Async is also available as a collection of ES2015 modules in the new
async-espackage. (import {forEachSeries} from 'async-es') (#984, #996)Added
race, analogous toPromise.race(). It will run an array of async tasks in parallel and will call its callback with the result of the first task to respond. (#568, #1038)Collection methods now accept ES2015 iterators. Maps, Sets, and anything that implements the iterator spec can now be passed directly to
each,map,parallel, etc.. (#579, #839, #1074)Added
mapValues, for mapping over the properties of an object and returning an object with the same keys. (#1157, #1177)Added
timeout, a wrapper for an async function that will make the task time-out after the specified time. (#1007, #1027)Added
reflectandreflectAll, analagous toPromise.reflect(), a wrapper for async tasks that always succeeds, by gathering results and errors into an object. (#942, #1012, #1095)constantsupports dynamic arguments -- it will now always use its last argument as the callback. (#1016, #1052)setImmediateandnextTicknow support arguments to partially apply to the deferred function, like the node-native versions do. (#940, #1053)autonow supports resolving cyclic dependencies using Kahn's algorithm (#1140).Added
autoInject, a relative ofautothat automatically spreads a task's dependencies as arguments to the task function. (#608, #1055, #1099, #1100)You can now limit the concurrency of
autotasks. (#635, #637)Added
retryable, a relative ofretrythat wraps an async function, making it retry when called.retrynow supports specifying a function that determines the next time interval, useful for exponential backoff, logging and other retry strategies.retrywill now pass all of the arguments the task function was resolved with to the callback (#1231).Added
q.unsaturated-- callback called when aqueue's number of running workers falls below a threshold. (#868, #1030, #1033, #1034)Added
q.error-- a callback called whenever aqueuetask calls its callback with an error.applyEachandapplyEachSeriesnow pass results to the final callback.
Breaking changes
- Breaking
Calling a callback more than once is considered an error, and an error will be thrown. This had an explicit breaking change in
waterfall. If you were relying on this behavior, you should more accurately represent your control flow as an event emitter or stream. (#814, #815, #1048, #1050) - Breaking
autotask functions now always take the callback as the last argument. If a task has dependencies, theresultsobject will be passed as the first argument. To migrate old task functions, wrap them with_.flip(#1036, #1042) - Breaking
Internal
setImmediatecalls have been refactored away. This may make existing flows vulnerable to stack overflows if you use many synchronous functions in series. UseensureAsyncto work around this. (#696, #704, #1049, #1050) - Breaking
mapused to return an object when iterating over an object.mapnow always returns an array, like in other libraries. The previous object behavior has been split out intomapValues. (#1157, #1177) - Breaking
filter,reject,some,every, and related functions now expect an error as the first callback argument, rather than just a simple boolean. Passnullas the first argument, or usefs.accessinstead offs.exists. (#118, #774, #1028, #1041) - Breaking
{METHOD}and{METHOD}Seriesare now implemented in terms of{METHOD}Limit. This is a major internal simplification, and is not expected to cause many problems, but it does subtly affect how functions execute internally. (#778, #847) - Breaking
retry's callback is now optional. Previously, omitting the callback would partially apply the function, meaning it could be passed directly as a task toseriesorauto. The partially applied "control-flow" behavior has been separated out intoretryable. (#1054, #1058) - Breaking
The test function for
whilst,until, andduringused to be passed non-error args from the iteratee function's callback, but this led to weirdness where the first call of the test function would be passed no args. We have made it so the test function is never passed extra arguments, and only thedoWhilst,doUntil, anddoDuringfunctions pass iteratee callback arguments to the test function (#1217, #1224) - Breaking
The
q.tasksarray has been renamedq._tasksand is now implemented as a doubly linked list (DLL). Any code that used to interact with this array will need to be updated to either use the provided helpers or support DLLs (#1205). - Breaking
The timing of the
q.saturated()callback in aqueuehas been modified to better reflect when tasks pushed to the queue will start queueing. (#724, #1078) - Breaking
Removed
iteratormethod in favour of ES2015 iterator protocol which natively supports arrays - Breaking
Dropped support for Component, Jam, SPM, and Volo (#1175, ##176)
Bug Fixes
Improved handling of no dependency cases in
auto&autoInject(#1147).Fixed a bug where the callback generated by
asyncifywithPromisescould resolve twice (#1197).Fixed several documented optional callbacks not actually being optional (#1223).
Other
Added
someSeriesandeverySeriesfor symmetry, as well as a complete set ofany/anyLimit/anySeriesandall//allLmit/allSeriesaliases.Added
findas an alias fordetect. (as well asfindLimitandfindSeries`).Various doc fixes (#1005, #1008, #1010, #1015, #1021, #1037, #1039, #1051, #1102, #1107, #1121, #1123, #1129, #1135, #1138, #1141, #1153, #1216, #1217, #1232, #1233, #1236, #1238)
- 1.x
1.5.1
2 Jan 2016Fix issue with
pauseinqueuewith concurrency enabledwhileanduntilnow pass the final result to callbackautowill properly handle concurrency when there is no callback
1.5.0
26 Oct 2015Added
transform, analogous to_.transformmapnow returns an object when an object is passed in, rather than array with non-numeric keys.mapwill begin always returning an array with numeric indexes in the next major release.autonow accepts an optionalconcurrencyargument to limit the number o. running tasks
Added
transform, analogous to_.transformmapnow returns an object when an object is passed in, rather than array with non-numeric keys.mapwill begin always returning an array with numeric indexes in the next major release.autonow accepts an optionalconcurrencyargument to limit the number o. running tasksAdded
queue#workersList(), to retrieve the lis. of currently running tasks.
1.4.2
9 Aug 2015Ensure coverage files don't get published on npm
1.4.1
7 Aug 2015Add in overlooked
detectLimitmethodRemoved unnecessary files from npm releases
Removed usage of a reserved word to prevent :boom: in older environments
1.4.0
20 Jul 2015asyncifynow supports promisesAdded
Limitversions offilterandreject
1.3.0
29 Jun 2015Added
constantAdded
duringanddoDuring, which are likewhilstwith an async truth test.
New Features:
Added
constantAdded
asyncify/wrapSyncfor making sync functions work with callbacks. (#671, #806)Added
duringanddoDuring, which are likewhilstwith an async truth test.retrynow accepts anintervalparameter to specify a delay between retries.asyncshould work better in Web Workers due to betterrootdetectionCallbacks are now optional in
whilst,doWhilst,until, anddoUntil
Bug Fixes:
1.2.1
8 Jun 2015Small regression with synchronous iterator behavior in
eachSerieswith a 1-element array. Before 1.1.0,eachSeries's callback was called on the same tick, which this patch restores. In 2.0.0, it will be called on the next tick.
Bug Fix:
Small regression with synchronous iterator behavior in
eachSerieswith a 1-element array. Before 1.1.0,eachSeries's callback was called on the same tick, which this patch restores. In 2.0.0, it will be called on the next tick.
1.1.1
8 Jun 2015Small regression with synchronous iterator behavior in
eachSerieswith a 1-element array. Before 1.1.0,eachSeries's callback was called on the same tick, which this patch restores. In 2.0.0, it will be called on the next tick.
Bug Fix:
Small regression with synchronous iterator behavior in
eachSerieswith a 1-element array. Before 1.1.0,eachSeries's callback was called on the same tick, which this patch restores. In 2.0.0, it will be called on the next tick.
1.1.0
1 Jun 2015cargonow supports all of the same methods and event callbacks asqueue.Added
ensureAsync- A wrapper that ensures an async function calls its callback on a later tick.Optimized
map,eachOf, andwaterfallfamilies of functions
New Features:
cargonow supports all of the same methods and event callbacks asqueue.Added
ensureAsync- A wrapper that ensures an async function calls its callback on a later tick.Optimized
map,eachOf, andwaterfallfamilies of functionsPassing a
nullorundefinedarray tomap,each,paralleland families will be treated as an empty array (#667).The callback is now optional for the composed results of
composeandseq.Reduced file size by 4kb, (minified version by 1kb)
Added code coverage through
nycandcoveralls
Bug Fixes:
foreverwill no longer stack overflow with a synchronous iteratoreachLimitand other limit functions will stop iterating once an error occursAlways pass
nullin callbacks when there is no errorEnsure proper conditions when calling
drain()after pushing an empty data set to a queueeachand family will properly handle an empty arrayeachSeriesand family will finish if the underlying array is modified during executionqueuewill throw if a non-function is passed toq.push()
1.0.0
20 May 2015Start using a changelog!
Detect deadlocks in
auto
No known breaking changes, we are simply complying with semver from here on out.
Changes:
Start using a changelog!
Add
forEachOffor iterating over Objects (or to iterate Arrays with indexes available) (#168 #704 #321)Detect deadlocks in
autoBetter support for require.js
Throw if queue created with concurrency
0Fix unneeded iteration in
queue.resume()Guard against timer mocking overriding
setImmediate(#609 #611)Miscellaneous doc fixes (#542 #596 #615 #628 #631 #690 #729)
Use single noop function internally
Optimize internal
_each,_mapand_keysfunctions.
- 0.9.x
- 0.8.x
0.8.0
29 Apr 2014- 0.7.x
0.7.0
7 Apr 2014- 0.6.x
- 0.5.x
0.5.0
30 Mar 2014- 0.4.x
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.