basant307/AI_Governance_Project
048
12 34[](https://www.npmjs.com/package/async)5[](https://coveralls.io/r/caolan/async?branch=master)6[](https://gitter.im/caolan/async?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)7[](https://www.jsdelivr.com/package/npm/async)8 9<!--10|Linux|Windows|MacOS|11|-|-|-|12|[](https://dev.azure.com/caolanmcmahon/async/_build/latest?definitionId=1&branchName=master) | [](https://dev.azure.com/caolanmcmahon/async/_build/latest?definitionId=1&branchName=master) | [](https://dev.azure.com/caolanmcmahon/async/_build/latest?definitionId=1&branchName=master)| -->13 14Async is a utility module which provides straight-forward, powerful functions for working with [asynchronous JavaScript](http://caolan.github.io/async/v3/global.html). Although originally designed for use with [Node.js](https://nodejs.org/) 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.15 16A pure ESM version of Async is available as [`async-es`](https://www.npmjs.com/package/async-es).17 18For Documentation, visit <https://caolan.github.io/async/>19 20*For Async v1.5.x documentation, go [HERE](https://github.com/caolan/async/blob/v1.5.2/README.md)*21 22 23```javascript24// for use with Node-style callbacks...25var async = require("async");26 27var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"};28var configs = {};29 30async.forEachOf(obj, (value, key, callback) => {31 fs.readFile(__dirname + value, "utf8", (err, data) => {32 if (err) return callback(err);33 try {34 configs[key] = JSON.parse(data);35 } catch (e) {36 return callback(e);37 }38 callback();39 });40}, err => {41 if (err) console.error(err.message);42 // configs is now a map of JSON data43 doSomethingWith(configs);44});45```46 47```javascript48var async = require("async");49 50// ...or ES2017 async functions51async.mapLimit(urls, 5, async function(url) {52 const response = await fetch(url)53 return response.body54}, (err, results) => {55 if (err) throw err56 // results is now an array of the response bodies57 console.log(results)58})59```60 