db3ebd0df0 | ||
---|---|---|
.. | ||
dist | ||
internal | ||
CHANGELOG.md | ||
LICENSE | ||
README.md | ||
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 | ||
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 | ||
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 | ||
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 | ||
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 |
README.md
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 install --save async
, it can also be used directly in the browser.
This version of the package is optimized for the Node.js environment. If you use Async with webpack, install async-es
instead.
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)
})