

\href{https://travis-ci.org/caolan/async}{\texttt{ }} \href{https://www.npmjs.com/package/async}{\texttt{ }} \href{https://coveralls.io/r/caolan/async?branch=master}{\texttt{ }} \href{https://gitter.im/caolan/async?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge}{\texttt{ }} \href{https://www.libhive.com/providers/npm/packages/async}{\texttt{ }} \href{https://www.jsdelivr.com/package/npm/async}{\texttt{ }}

Async is a utility module which provides straight-\/forward, powerful functions for working with \href{http://caolan.github.io/async/global.html}{\texttt{ asynchronous Java\+Script}}. Although originally designed for use with \href{https://nodejs.org/}{\texttt{ Node.\+js}} and installable via {\ttfamily npm install -\/-\/save async}, it can also be used directly in the browser.

This version of the package is optimized for the Node.\+js environment. If you use Async with webpack, install \href{https://www.npmjs.com/package/async-es}{\texttt{ {\ttfamily async-\/es}}} instead.

For Documentation, visit \href{https://caolan.github.io/async/}{\texttt{ https\+://caolan.\+github.\+io/async/}}

{\itshape For Async v1.\+5.\+x documentation, go \href{https://github.com/caolan/async/blob/v1.5.2/README.md}{\texttt{ HERE}}}


\begin{DoxyCode}{0}
\DoxyCodeLine{// for use with Node-\/style callbacks...}
\DoxyCodeLine{var async = require("{}async"{});}
\DoxyCodeLine{}
\DoxyCodeLine{var obj = \{dev: "{}/dev.json"{}, test: "{}/test.json"{}, prod: "{}/prod.json"{}\};}
\DoxyCodeLine{var configs = \{\};}
\DoxyCodeLine{}
\DoxyCodeLine{async.forEachOf(obj, (value, key, callback) => \{}
\DoxyCodeLine{    fs.readFile(\_\_dirname + value, "{}utf8"{}, (err, data) => \{}
\DoxyCodeLine{        if (err) return callback(err);}
\DoxyCodeLine{        try \{}
\DoxyCodeLine{            configs[key] = JSON.parse(data);}
\DoxyCodeLine{        \} catch (e) \{}
\DoxyCodeLine{            return callback(e);}
\DoxyCodeLine{        \}}
\DoxyCodeLine{        callback();}
\DoxyCodeLine{    \});}
\DoxyCodeLine{\}, err => \{}
\DoxyCodeLine{    if (err) console.error(err.message);}
\DoxyCodeLine{    // configs is now a map of JSON data}
\DoxyCodeLine{    doSomethingWith(configs);}
\DoxyCodeLine{\}); }

\end{DoxyCode}



\begin{DoxyCode}{0}
\DoxyCodeLine{var async = require("{}async"{});}
\DoxyCodeLine{}
\DoxyCodeLine{// ...or ES2017 async functions}
\DoxyCodeLine{async.mapLimit(urls, 5, async function(url) \{}
\DoxyCodeLine{    const response = await fetch(url)}
\DoxyCodeLine{    return response.body}
\DoxyCodeLine{\}, (err, results) => \{}
\DoxyCodeLine{    if (err) throw err}
\DoxyCodeLine{    // results is now an array of the response bodies}
\DoxyCodeLine{    console.log(results)}
\DoxyCodeLine{\}) }

\end{DoxyCode}
 