async
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/async package

3.2.6 • Public • Published

Async Logo

Github Actions CI status NPM version Coverage Status Join the chat at https://gitter.im/caolan/async 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 i async, it can also be used directly in the browser. An 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)
})

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
3.2.618,570,546latest
3.1.046,939next

Version History

VersionDownloads (Last 7 Days)Published
3.2.618,570,546
3.2.56,363,621
3.2.45,822,109
2.6.410,585,865
3.2.32,010,061
3.2.2207,525
3.2.1121,080
3.2.0770,834
3.1.117,686
2.6.32,247,343
3.1.046,939
3.0.14,802
3.0.02,059
2.6.2229,544
2.6.1485,231
2.6.0165,624
2.5.095,834
2.4.118,189
2.4.04,233
2.3.013,130
2.2.01,711
2.1.556,849
2.1.427,171
2.1.210,619
2.1.1330
2.1.0220
2.0.161,898
2.0.02,532
2.0.0-rc.6105
2.0.0-rc.53,382
2.0.0-rc.4224
2.0.0-rc.3863
2.0.0-rc.2297
2.0.0-rc.130
2.0.0-alpha.027
1.5.23,184,113
1.5.12,546
1.5.0124,243
1.4.235,470
1.4.126
1.4.05,411
1.3.02,444
1.2.133,535
1.1.128
1.2.0520
1.1.035
1.0.0382,154
0.9.21,164,539
0.9.0226,102
0.8.046,676
0.7.05,792
0.6.211,926
0.6.132
0.6.025
0.5.027
0.4.141
0.4.037
0.3.041
0.2.102,004,494
0.2.9105,562
0.2.83,731
0.2.7199,484
0.2.631,716
0.2.51,350
0.2.429
0.2.324
0.2.228
0.2.127
0.2.029
0.1.22162,283
0.1.2129
0.1.2024
0.1.1932
0.1.18318
0.1.1725
0.1.1629
0.1.156,159
0.1.1427
0.1.1333
0.1.1230
0.1.1138
0.1.1028
0.1.9697
0.1.825
0.1.226
0.1.428
0.1.331
0.1.526
0.1.626
0.1.731
0.1.128
0.1.050

Package Sidebar

Install

npm i async

Weekly Downloads

55,690,932

Version

3.2.6

License

MIT

Unpacked Size

808 kB

Total Files

137

Last publish

Collaborators

  • beaugunderson
  • caolan
  • aearly
  • megawac
  • hargasinski