JSPM

  • Created
  • Published
  • Downloads 56305521
  • Score
    100M100P100Q210059F
  • License MIT

Higher-order functions and common patterns for asynchronous code

Package Exports

  • async
  • async/apply
  • async/apply.js
  • async/asyncify
  • async/asyncify.js
  • async/auto
  • async/auto.js
  • async/cargo
  • async/cargo.js
  • async/concat
  • async/concat.js
  • async/constant
  • async/constant.js
  • async/detect
  • async/detect.js
  • async/detectLimit
  • async/detectLimit.js
  • async/detectSeries
  • async/detectSeries.js
  • async/dist/async.js
  • async/dist/async.mjs
  • async/doUntil
  • async/doUntil.js
  • async/doWhilst
  • async/doWhilst.js
  • async/each
  • async/each.js
  • async/eachLimit
  • async/eachLimit.js
  • async/eachOf
  • async/eachOf.js
  • async/eachOfLimit
  • async/eachOfLimit.js
  • async/eachOfSeries
  • async/eachOfSeries.js
  • async/eachSeries
  • async/eachSeries.js
  • async/every
  • async/every.js
  • async/filter
  • async/filter.js
  • async/filterSeries
  • async/filterSeries.js
  • async/forEach
  • async/forEach.js
  • async/forEachLimit
  • async/forEachLimit.js
  • async/forever
  • async/forever.js
  • async/map
  • async/map.js
  • async/mapLimit
  • async/mapLimit.js
  • async/mapSeries
  • async/mapSeries.js
  • async/mapValues
  • async/mapValues.js
  • async/memoize
  • async/memoize.js
  • async/nextTick
  • async/nextTick.js
  • async/parallel
  • async/parallel.js
  • async/parallelLimit
  • async/parallelLimit.js
  • async/priorityQueue
  • async/priorityQueue.js
  • async/queue
  • async/queue.js
  • async/race
  • async/race.js
  • async/reduce
  • async/reduce.js
  • async/reflect
  • async/reflect.js
  • async/reject
  • async/reject.js
  • async/retry
  • async/retry.js
  • async/seq
  • async/seq.js
  • async/series
  • async/series.js
  • async/setImmediate
  • async/setImmediate.js
  • async/some
  • async/some.js
  • async/someLimit
  • async/someLimit.js
  • async/someSeries
  • async/someSeries.js
  • async/timeout
  • async/timeout.js
  • async/times
  • async/times.js
  • async/timesLimit
  • async/timesLimit.js
  • async/timesSeries
  • async/timesSeries.js
  • async/tryEach
  • async/tryEach.js
  • async/until
  • async/until.js
  • async/waterfall
  • async/waterfall.js
  • async/whilst
  • async/whilst.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (async) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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