async
    Overview
    Documentation
    Insights
    Code
    Contributors
    Dependencies
    Alternatives

async

Higher-order functions and common patterns for asynchronous code

3.1.0  •  Published 5 months ago  •  by Caolan McMahon  •  MIT License

Async Logo

Build Status via Travis CI NPM version Coverage Status Join the chat at https://gitter.im/caolan/async 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)
})

Popularity

Weekly Downloads
23.9M
Stars
26.1K

Maintenance

Development

Last ver 5 months ago
Created 9 years ago
Last commit 2 months ago
2 days between commits

Technology

Node version: 10.15.3
693.7K unpacked

Compliance

MIT License
OSI Approved
0 vulnerabilities

Contributors

119 contributors
Alexander Early
Maintainer, 453 commits, 184 merges, 40 PRs
Works at npm
Graeme Yeates
Maintainer, 199 commits, 80 merges, 65 PRs
Works at Clearpath Robotics
Caolan McMahon
Maintainer, 109 merges
Hubert Argasinski
Maintainer, 65 commits, 19 merges, 21 PRs
charlierudolph
62 commits
Ivan Seidel
30 commits, 4 PRs
Works at TendaDigital

Tags

async
callback
module
utility
Ready for the next level?
Join Devstore's founding team to help us build the ultimate open-source app store, work with the latest technologies, and enjoy great culture, impact and autonomy
© 2019 Devstore, Inc.
Devstore helps developers find and use open-source packages, so they can focus on building amazing things