Eric Foster 35b96bc934 initial commit 6 年前
..
dist initial commit 6 年前
internal initial commit 6 年前
CHANGELOG.md initial commit 6 年前
LICENSE initial commit 6 年前
README.md initial commit 6 年前
all.js initial commit 6 年前
allLimit.js initial commit 6 年前
allSeries.js initial commit 6 年前
any.js initial commit 6 年前
anyLimit.js initial commit 6 年前
anySeries.js initial commit 6 年前
apply.js initial commit 6 年前
applyEach.js initial commit 6 年前
applyEachSeries.js initial commit 6 年前
asyncify.js initial commit 6 年前
auto.js initial commit 6 年前
autoInject.js initial commit 6 年前
bower.json initial commit 6 年前
cargo.js initial commit 6 年前
compose.js initial commit 6 年前
concat.js initial commit 6 年前
concatLimit.js initial commit 6 年前
concatSeries.js initial commit 6 年前
constant.js initial commit 6 年前
detect.js initial commit 6 年前
detectLimit.js initial commit 6 年前
detectSeries.js initial commit 6 年前
dir.js initial commit 6 年前
doDuring.js initial commit 6 年前
doUntil.js initial commit 6 年前
doWhilst.js initial commit 6 年前
during.js initial commit 6 年前
each.js initial commit 6 年前
eachLimit.js initial commit 6 年前
eachOf.js initial commit 6 年前
eachOfLimit.js initial commit 6 年前
eachOfSeries.js initial commit 6 年前
eachSeries.js initial commit 6 年前
ensureAsync.js initial commit 6 年前
every.js initial commit 6 年前
everyLimit.js initial commit 6 年前
everySeries.js initial commit 6 年前
filter.js initial commit 6 年前
filterLimit.js initial commit 6 年前
filterSeries.js initial commit 6 年前
find.js initial commit 6 年前
findLimit.js initial commit 6 年前
findSeries.js initial commit 6 年前
foldl.js initial commit 6 年前
foldr.js initial commit 6 年前
forEach.js initial commit 6 年前
forEachLimit.js initial commit 6 年前
forEachOf.js initial commit 6 年前
forEachOfLimit.js initial commit 6 年前
forEachOfSeries.js initial commit 6 年前
forEachSeries.js initial commit 6 年前
forever.js initial commit 6 年前
groupBy.js initial commit 6 年前
groupByLimit.js initial commit 6 年前
groupBySeries.js initial commit 6 年前
index.js initial commit 6 年前
inject.js initial commit 6 年前
log.js initial commit 6 年前
map.js initial commit 6 年前
mapLimit.js initial commit 6 年前
mapSeries.js initial commit 6 年前
mapValues.js initial commit 6 年前
mapValuesLimit.js initial commit 6 年前
mapValuesSeries.js initial commit 6 年前
memoize.js initial commit 6 年前
nextTick.js initial commit 6 年前
package.json initial commit 6 年前
parallel.js initial commit 6 年前
parallelLimit.js initial commit 6 年前
priorityQueue.js initial commit 6 年前
queue.js initial commit 6 年前
race.js initial commit 6 年前
reduce.js initial commit 6 年前
reduceRight.js initial commit 6 年前
reflect.js initial commit 6 年前
reflectAll.js initial commit 6 年前
reject.js initial commit 6 年前
rejectLimit.js initial commit 6 年前
rejectSeries.js initial commit 6 年前
retry.js initial commit 6 年前
retryable.js initial commit 6 年前
select.js initial commit 6 年前
selectLimit.js initial commit 6 年前
selectSeries.js initial commit 6 年前
seq.js initial commit 6 年前
series.js initial commit 6 年前
setImmediate.js initial commit 6 年前
some.js initial commit 6 年前
someLimit.js initial commit 6 年前
someSeries.js initial commit 6 年前
sortBy.js initial commit 6 年前
timeout.js initial commit 6 年前
times.js initial commit 6 年前
timesLimit.js initial commit 6 年前
timesSeries.js initial commit 6 年前
transform.js initial commit 6 年前
tryEach.js initial commit 6 年前
unmemoize.js initial commit 6 年前
until.js initial commit 6 年前
waterfall.js initial commit 6 年前
whilst.js initial commit 6 年前
wrapSync.js initial commit 6 年前

README.md

Async Logo

Build Status via Travis CI NPM version Coverage Status libhive - Open source examples jsDelivr Hits

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)
})