async README

The project's README from github.com/caolan/async. As one markdown file: README.md.

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

async (caolan/async)

Searching Database…

28.1K ·GitHub
这是什么东西?Async 是一个实用工具模块,提供简洁而强大的函数来处理异步 JavaScript,最初是为 Node.js 设计的。
它是要添加到我代码里的库,还是需要单独运行的东西?它是一个库:安装到你的项目中,然后在自己的 JavaScript 代码里调用它的函数。不需要部署,也不能单独运行。
怎么把它加到 Node.js 项目里?在项目里运行 npm i async,然后导入这个模块就行了——安装步骤就这么多。
安装它会连带下载一堆其他依赖包吗?不会——这个仓库的 package.json 里没有声明任何运行时依赖,所以 npm i async 只会安装这一个模块。
它支持现代的 ES module 导入方式吗?支持——而且对于纯 ESM 项目,还有一个专门的包 async-es,它是 Async 的纯 ESM 版本。
在浏览器里也能用吗,还是只能在服务器上用?能——除了 Node.js,它也可以直接在浏览器里使用。主包还附带 ESM/MJS 版本,Webpack、Rollup 这类打包工具会自动识别。
这些工具函数到底能帮我做什么?README 只说了大概:用于处理异步 JavaScript 的函数。完整的 API 参考在仓库链接的文档里。
这是一个成熟、还在积极维护的项目吗?非常成熟——仓库创建于 2010 年 6 月,在 GitHub 上有大约 28,000 个 star,而且没有被归档。
我能在商业项目里用它吗?可以。Async 采用 MIT 许可证,可以自由使用、修改和分发,包括用在商业产品中。
What are similar projects?lollipop-css, prism, date-fns, classnames, core-js, joi, mongoose, comlink
Creator
caolan
Size
8.8 MB
Stars
28.1K
Age
16y
Commits · 90 Days