async
    Overview
    Playground
    Code
    Issues
    Career Opportunities
    Alternatives
    Dependencies
    Documentation
    Find an Expert
    Versions
    Insights & Analysis

async

Higher-order functions and common patterns for asynchronous code

3.1.0  •  Published 2 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)
})

Tags

async
callback
module
utility
Get an open source license report with a click
Whether it's for legal, customers or investors, upload your package.json files, and get a comprehensive license report page and spreadsheet. No hassle, it just works!
$49 one time fee, money back guarantee

Popularity

Weekly Downloads
23.9M
Stars
25.8K

Issues and PRs

Activity

Last ver 2 months ago
Created 9 years ago
Last commit 2 months ago
1 day between commits

Sustainability

118 contributors

Technology

Node version: 10.15.3
693.7K unpacked

Legal and Compliance

MIT License
OSI Approved
0 vulnerabilities

Top Experts

Alexander Early
Maintainer, 453 commits, 183 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
63 commits
Ivan Seidel
30 commits, 4 PRs
Works at TendaDigital