async
    Overview
    Documentation
    Tutorials
    Chat
    Insights
    Code
    Dependencies
    Contributors
    Jobs

async

Higher-order functions and common patterns for asynchronous code

3.1.0  •  Updated 9 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

Maintenance

Development

Last ver 10 months ago
Created 9 years ago
Last commit 6 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
Openbase helps developers choose among and use millions of open-source packages, so they can build amazing products faster.
FacebookTwitterLinkedIn
© 2020 Devstore, Inc.