.. | ||
dist | ||
internal | ||
all.js | ||
allLimit.js | ||
allSeries.js | ||
any.js | ||
anyLimit.js | ||
anySeries.js | ||
apply.js | ||
applyEach.js | ||
applyEachSeries.js | ||
asyncify.js | ||
auto.js | ||
autoInject.js | ||
bower.json | ||
cargo.js | ||
cargoQueue.js | ||
CHANGELOG.md | ||
compose.js | ||
concat.js | ||
concatLimit.js | ||
concatSeries.js | ||
constant.js | ||
detect.js | ||
detectLimit.js | ||
detectSeries.js | ||
dir.js | ||
doDuring.js | ||
doUntil.js | ||
doWhilst.js | ||
during.js | ||
each.js | ||
eachLimit.js | ||
eachOf.js | ||
eachOfLimit.js | ||
eachOfSeries.js | ||
eachSeries.js | ||
ensureAsync.js | ||
every.js | ||
everyLimit.js | ||
everySeries.js | ||
filter.js | ||
filterLimit.js | ||
filterSeries.js | ||
find.js | ||
findLimit.js | ||
findSeries.js | ||
flatMap.js | ||
flatMapLimit.js | ||
flatMapSeries.js | ||
foldl.js | ||
foldr.js | ||
forEach.js | ||
forEachLimit.js | ||
forEachOf.js | ||
forEachOfLimit.js | ||
forEachOfSeries.js | ||
forEachSeries.js | ||
forever.js | ||
groupBy.js | ||
groupByLimit.js | ||
groupBySeries.js | ||
index.js | ||
inject.js | ||
LICENSE | ||
log.js | ||
map.js | ||
mapLimit.js | ||
mapSeries.js | ||
mapValues.js | ||
mapValuesLimit.js | ||
mapValuesSeries.js | ||
memoize.js | ||
nextTick.js | ||
package.json | ||
parallel.js | ||
parallelLimit.js | ||
priorityQueue.js | ||
queue.js | ||
race.js | ||
README.md | ||
reduce.js | ||
reduceRight.js | ||
reflect.js | ||
reflectAll.js | ||
reject.js | ||
rejectLimit.js | ||
rejectSeries.js | ||
retry.js | ||
retryable.js | ||
select.js | ||
selectLimit.js | ||
selectSeries.js | ||
seq.js | ||
series.js | ||
setImmediate.js | ||
some.js | ||
someLimit.js | ||
someSeries.js | ||
sortBy.js | ||
timeout.js | ||
times.js | ||
timesLimit.js | ||
timesSeries.js | ||
transform.js | ||
tryEach.js | ||
unmemoize.js | ||
until.js | ||
waterfall.js | ||
whilst.js | ||
wrapSync.js |
Async is a utility module which provides straight-forward, powerful functions for working with asynchronous JavaScript. Although originally designed for use with Node.js and installable via npm i async
, it can also be used directly in the browser. A ESM/MJS version is included in the main async
package that should automatically be used with compatible bundlers such as Webpack and Rollup.
A pure ESM version of Async is available as async-es
.
For Documentation, visit https://caolan.github.io/async/
For Async v1.5.x documentation, go HERE
// for use with Node-style callbacks...
var async = require("async");
var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"};
var configs = {};
async.forEachOf(obj, (value, key, callback) => {
fs.readFile(__dirname + value, "utf8", (err, data) => {
if (err) return callback(err);
try {
configs[key] = JSON.parse(data);
} catch (e) {
return callback(e);
}
callback();
});
}, err => {
if (err) console.error(err.message);
// configs is now a map of JSON data
doSomethingWith(configs);
});
var async = require("async");
// ...or ES2017 async functions
async.mapLimit(urls, 5, async function(url) {
const response = await fetch(url)
return response.body
}, (err, results) => {
if (err) throw err
// results is now an array of the response bodies
console.log(results)
})