https://github.com/caolan/async
Async utilities for node and the browser
https://github.com/caolan/async
async callbacks javascript
Last synced: 7 days ago
JSON representation
Async utilities for node and the browser
- Host: GitHub
- URL: https://github.com/caolan/async
- Owner: caolan
- License: mit
- Created: 2010-06-01T21:01:30.000Z (almost 15 years ago)
- Default Branch: master
- Last Pushed: 2025-03-01T15:30:12.000Z (about 1 month ago)
- Last Synced: 2025-04-01T00:11:08.798Z (14 days ago)
- Topics: async, callbacks, javascript
- Language: JavaScript
- Homepage: http://caolan.github.io/async/
- Size: 7.52 MB
- Stars: 28,231
- Watchers: 652
- Forks: 2,404
- Open Issues: 11
-
Metadata Files:
- Readme: README.es.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Support: support/aliases.txt
Awesome Lists containing this project
- awesome-development - async - Provides straight-forward, powerful functions for working with asynchronousity. (Packages / Control flow)
- awesome - async - Async utilities for node and the browser (JavaScript)
- awesome-nodejs - async - Provides straight-forward, powerful functions for working with asynchronicity.  (Repository / Control flow)
- awesome-github-star - async
- awesome-list - async
- awesome - caolan / async
- awesome-node - async - Provides straight-forward, powerful functions for working with asynchronicity. (Packages / Control flow)
- awesome-nodejs-cn - async - 提供简单,强大的功能来处理异步问题. (目录 / 流程控制)
- awesome-star-libs - caolan / async
- awesome - async - Async utilities for node and the browser (JavaScript)
- jimsghstars - caolan/async - Async utilities for node and the browser (JavaScript)
- StarryDivineSky - caolan/async
- awesome-nodejs - async - Async utilities for node and the browser - ★ 24879 (Control flow)
- awesome-javascript - async - Async utilities for node and the browser - ★ 24879 (Control Flow)
- awesome-nodejs-cn - async - 提供简单,强大的功能来处理异步问题 (包 / 流程控制)
README


[](https://www.npmjs.com/package/async)
[](https://coveralls.io/r/caolan/async?branch=master)
[](https://gitter.im/caolan/async?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[](https://www.jsdelivr.com/package/npm/async)Async is a utility module which provides straight-forward, powerful functions for working with [asynchronous JavaScript](http://caolan.github.io/async/global.html). Although originally designed for use with [Node.js](https://nodejs.org/) and installable via `npm install --save async`, it can also be used directly in the browser.
This version of the package is optimized for building with webpack. If you use Async in Node.js, install [`async`](https://www.npmjs.com/package/async) instead.
For Documentation, visit
*For Async v1.5.x documentation, go [HERE](https://github.com/caolan/async/blob/v1.5.2/README.md)*
```javascript
// for use with callbacks...
import { forEachOf } from "async-es";const images = {cat: "/cat.png", dog: "/dog.png", duck: "/duck.png"};
const sizes = {};forEachOf(images, (value, key, callback) => {
const imageElem = new Image();
imageElem.src = value;
imageElem.addEventListener("load", () => {
sizes[key] = {
width: imageElem.naturalWidth,
height: imageElem.naturalHeight,
};
callback();
});
imageElem.addEventListener("error", (e) => {
callback(e);
});
}, err => {
if (err) console.error(err.message);
// `sizes` is now a map of image sizes
doSomethingWith(sizes);
});
``````javascript
import { mapLimit } from "async-es";// ...or ES2017 async functions
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)
})
```