You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Michael Winter 555e2c196e | 5 years ago | |
---|---|---|
.. | ||
dist | 5 years ago | |
internal | 5 years ago | |
CHANGELOG.md | 5 years ago | |
LICENSE | 5 years ago | |
README.md | 5 years ago | |
all.js | 5 years ago | |
allLimit.js | 5 years ago | |
allSeries.js | 5 years ago | |
any.js | 5 years ago | |
anyLimit.js | 5 years ago | |
anySeries.js | 5 years ago | |
apply.js | 5 years ago | |
applyEach.js | 5 years ago | |
applyEachSeries.js | 5 years ago | |
asyncify.js | 5 years ago | |
auto.js | 5 years ago | |
autoInject.js | 5 years ago | |
bower.json | 5 years ago | |
cargo.js | 5 years ago | |
cargoQueue.js | 5 years ago | |
compose.js | 5 years ago | |
concat.js | 5 years ago | |
concatLimit.js | 5 years ago | |
concatSeries.js | 5 years ago | |
constant.js | 5 years ago | |
detect.js | 5 years ago | |
detectLimit.js | 5 years ago | |
detectSeries.js | 5 years ago | |
dir.js | 5 years ago | |
doDuring.js | 5 years ago | |
doUntil.js | 5 years ago | |
doWhilst.js | 5 years ago | |
during.js | 5 years ago | |
each.js | 5 years ago | |
eachLimit.js | 5 years ago | |
eachOf.js | 5 years ago | |
eachOfLimit.js | 5 years ago | |
eachOfSeries.js | 5 years ago | |
eachSeries.js | 5 years ago | |
ensureAsync.js | 5 years ago | |
every.js | 5 years ago | |
everyLimit.js | 5 years ago | |
everySeries.js | 5 years ago | |
filter.js | 5 years ago | |
filterLimit.js | 5 years ago | |
filterSeries.js | 5 years ago | |
find.js | 5 years ago | |
findLimit.js | 5 years ago | |
findSeries.js | 5 years ago | |
flatMap.js | 5 years ago | |
flatMapLimit.js | 5 years ago | |
flatMapSeries.js | 5 years ago | |
foldl.js | 5 years ago | |
foldr.js | 5 years ago | |
forEach.js | 5 years ago | |
forEachLimit.js | 5 years ago | |
forEachOf.js | 5 years ago | |
forEachOfLimit.js | 5 years ago | |
forEachOfSeries.js | 5 years ago | |
forEachSeries.js | 5 years ago | |
forever.js | 5 years ago | |
groupBy.js | 5 years ago | |
groupByLimit.js | 5 years ago | |
groupBySeries.js | 5 years ago | |
index.js | 5 years ago | |
inject.js | 5 years ago | |
log.js | 5 years ago | |
map.js | 5 years ago | |
mapLimit.js | 5 years ago | |
mapSeries.js | 5 years ago | |
mapValues.js | 5 years ago | |
mapValuesLimit.js | 5 years ago | |
mapValuesSeries.js | 5 years ago | |
memoize.js | 5 years ago | |
nextTick.js | 5 years ago | |
package.json | 5 years ago | |
parallel.js | 5 years ago | |
parallelLimit.js | 5 years ago | |
priorityQueue.js | 5 years ago | |
queue.js | 5 years ago | |
race.js | 5 years ago | |
reduce.js | 5 years ago | |
reduceRight.js | 5 years ago | |
reflect.js | 5 years ago | |
reflectAll.js | 5 years ago | |
reject.js | 5 years ago | |
rejectLimit.js | 5 years ago | |
rejectSeries.js | 5 years ago | |
retry.js | 5 years ago | |
retryable.js | 5 years ago | |
select.js | 5 years ago | |
selectLimit.js | 5 years ago | |
selectSeries.js | 5 years ago | |
seq.js | 5 years ago | |
series.js | 5 years ago | |
setImmediate.js | 5 years ago | |
some.js | 5 years ago | |
someLimit.js | 5 years ago | |
someSeries.js | 5 years ago | |
sortBy.js | 5 years ago | |
timeout.js | 5 years ago | |
times.js | 5 years ago | |
timesLimit.js | 5 years ago | |
timesSeries.js | 5 years ago | |
transform.js | 5 years ago | |
tryEach.js | 5 years ago | |
unmemoize.js | 5 years ago | |
until.js | 5 years ago | |
waterfall.js | 5 years ago | |
whilst.js | 5 years ago | |
wrapSync.js | 5 years ago |
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 async
, it can also be used directly in the browser. A ESM 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)
})