Async: async npm library for control flow
Async has survived the shift from callbacks to native promises because it never forced a choice between them — its own README wraps an ES2017 async function inside async.mapLimit with no adapter code. That's the real value: one set of control-flow helpers for both callback and async/await code. It's not a Promise.all replacement for a simple parallel run; it earns its keep once you need mapLimit's concurrency cap instead of hand-rolling one.
What is Async?
Async is an npm utility module, installed with npm i async, for working with asynchronous JavaScript in both Node.js and the browser. It bundles an ESM/MJS build that bundlers like Webpack and Rollup pick up automatically, and its functions accept either Node-style callbacks or ES2017 async/await — forEachOf and mapLimit are two examples shown in its own README. A separate pure-ESM package, async-es, is also available.
Core async utilities included
- ✓forEachOf iterates over an object or array and runs an async callback for each entry, collecting one final error instead of you tracking completion yourself.
- ✓mapLimit runs an async function over a list with a concurrency cap — the README example caps it at 5 in-flight calls.
- ✓Functions accept either Node-style error-first callbacks or ES2017 async/await functions, shown side by side in the README's two examples.
- ✓Ships an ESM/MJS build inside the main async package that Webpack and Rollup pick up automatically, no separate config needed.
- ✓A pure-ESM package, async-es, is published separately for projects that want an ESM-only dependency.
- ✓Works directly in the browser as well as Node.js.
Installing Async via npm
Install with npm i async. That pulls in the main package, which is CommonJS-first but includes an ESM/MJS build that compatible bundlers such as Webpack and Rollup use automatically — no separate flag needed. If you want a pure-ESM dependency instead, install async-es rather than async. Full API documentation lives at caolan.github.io/async, separate from the README; the README doesn't document individual function signatures itself.
Using Async with callbacks and async/await
The README's first example requires async with require("async") and calls async.forEachOf on an object of file paths, reading and JSON-parsing each one inside the callback, then handling a single aggregated error in the final callback once every entry has finished. The second example calls async.mapLimit(urls, 5, ...) and passes it an ES2017 async function that awaits fetch(url) directly — Async runs that async function under the same concurrency-limited control flow, so callback-style and async/await code can sit side by side in the same project.
Strengths
- ✓Accepts both error-first callbacks and ES2017 async/await functions through the same API, so existing callback code doesn't need a rewrite to start using it.
- ✓Includes an ESM/MJS build inside the main package that Webpack and Rollup pick up automatically, plus async-es for a pure-ESM setup.
- ✓MIT licensed, so it drops into commercial and closed-source projects without licensing friction.
- ✓Runs unmodified in the browser as well as Node.js.
When Async is not the right choice
- △The README itself doesn't document individual function behavior — you have to visit the separate docs site to look up what each helper actually does.
- △Two overlapping packages, async and async-es, mean picking the right one for your module system instead of there being one obvious install.
- △Old enough to still link out to archived v1.5.x docs, so tutorials or answers written against that version won't match the current API.
Alternatives to Async
Frequently asked questions
The facts here don't include a specific 2024 commit date, but Async ships a current npm package alongside a maintained docs site and a separately archived v1.5.x reference for older versions — the kind of upkeep an abandoned project doesn't bother with.
Yes. Async installs via npm i async for Node.js, and the same package works directly in the browser too. It also bundles an ESM/MJS build that bundlers like Webpack and Rollup pick up automatically.
Async is released under the MIT license, a permissive license that allows commercial and closed-source use, modification, and redistribution — you just need to keep the original copyright notice intact.
Yes, Async supports ES modules. The main async package includes an ESM/MJS build that compatible bundlers pick up automatically, and a separate pure-ESM package, async-es, is available if you want an ESM-only dependency.
Async doesn't replace native Promises — its own README example wraps an ES2017 async function inside async.mapLimit rather than competing with it. Native Promise.all is simpler for a one-off parallel run; Async earns its place once you need a named helper like mapLimit's concurrency cap or forEachOf's object iteration.
The async package is CommonJS-first but bundles an ESM/MJS build that Webpack and Rollup pick up automatically. async-es is a separate, pure-ESM package for projects that want an ESM-only dependency without that auto-detection step. Both come from the same caolan/async project.
The problem it solves
Node's error-first callback style turns iterating over a list or object with async work — like reading several files — into either deep nesting or a hand-rolled counter to track when every callback has fired. Async's forEachOf function, used in its own README example to iterate over a config-file object, replaces that bookkeeping with one call that reports a single final error or none at all.
Best use cases
- •Reading and parsing several JSON config files into one object without nesting callbacks — the exact pattern in Async's own forEachOf README example.
- •Fetching a list of URLs with a concurrency cap instead of firing every request at once, the way async.mapLimit(urls, 5, ...) does in the README.
- •Gradually moving a Node-style callback codebase toward async/await, since Async's functions accept either style.
- •Bundling for the browser with Webpack or Rollup, where the included ESM/MJS build is picked up automatically.
Who should try it — and who should skip
Teams with existing Node-style callback code that need control-flow helpers — capped-concurrency iteration, for instance — without a full rewrite to promises get the most out of Async. A greenfield project starting from async/await with no callback legacy has less reason to add it: Promise.all and a plain loop cover the simple cases without another dependency.
Related repositories
Curious whether async is right for you?
Let ChatGPT, Claude, or Perplexity look into it — click below and see what AI actually says about async.
