diff options
Diffstat (limited to 'v3/docs.html')
-rw-r--r-- | v3/docs.html | 18466 |
1 files changed, 18466 insertions, 0 deletions
diff --git a/v3/docs.html b/v3/docs.html new file mode 100644 index 0000000..38f3e02 --- /dev/null +++ b/v3/docs.html @@ -0,0 +1,18466 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + + + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>async - Documentation</title> + + + <link rel="icon" href="favicon.ico?v=2"> + <link rel="stylesheet" href="https://cdn.jsdelivr.net/bootstrap/3.3.6/css/bootstrap.min.css"> + + <link rel="stylesheet" href="styles/prettify-tomorrow.css"> + + <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Montserrat:400,700"> + <link rel="stylesheet" href="styles/jsdoc-default.css"> + + <!--[if lt IE 9]> + <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> + <![endif]--> + <link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/ionicons/2.0.1/css/ionicons.min.css"> +</head> +<body> + +<div class="navbar navbar-default navbar-fixed-top"> + <div class="navbar-header"> + <a class="navbar-brand" href="../"> + <img src="img/async-logo.svg" alt="Async.js"> + </a> + </div> + <ul class="nav navbar-nav"> + <li id="version-dropdown" class="dropdown"> + <a href="#" class="dropdown-toggle vertically-centered" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">v3.0.1 <span class="caret"></span> + </a> + <ul class="dropdown-menu"> + <li><a href="../v3/">v3.0.x</a></li> + <li><a href="../v2/">v2.6.2</a></li> + <li> + <a href="https://github.com/caolan/async/blob/v1.5.2/README.md">v1.5.x</a> + </li> + </ul> + </li> + <li><a href="./index.html">Home</a></li> + <li><a href="./docs.html">Docs</a></li> + <li><a href="https://github.com/caolan/async/blob/master/CHANGELOG.md">Changelog</a></li> + <li><a href="https://github.com/caolan/async"><i class="ion-social-github" aria-hidden="true"></i></a></li> + </ul> + <ul class="nav navbar-nav navbar-right"> + <form class="navbar-form navbar-left" role="search"> + <div class="form-group"> + <input type="text" class="form-control typeahead" id="doc-search" placeholder="Search" autofocus> + </div> + </form> + </ul> +</div> + + +<input type="checkbox" id="nav-trigger" class="nav-trigger"> +<label for="nav-trigger" class="navicon-button x"> + <div class="navicon"></div> +</label> + +<label for="nav-trigger" class="overlay"></label> + +<div id="main"> + <div id="main-container" data-spy="scroll" data-target="#toc" data-offset="50"> + + <h1 class="page-title">async</h1> + + + + + + + +<section> + +<header> + + + + + +</header> + +<article> + <div class="container-overview"> + + + <div class="description"><p>Async is a utility module which provides straight-forward, powerful functions +for working with asynchronous JavaScript. Although originally designed for +use with <a href="http://nodejs.org">Node.js</a> and installable via +<code>npm install --save async</code>, it can also be used directly in the browser.</p></div> + + + + + + + + + + + + + + + + + + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="index.js.html">index.js</a>, <a href="index.js.html#line40">line 40</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><a href="global.html">AsyncFunction</a></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + </div> + + + + + + + + + + + + + + + + + + +</article> + +</section> + + + + + + + <h1 class="page-title" id="collections">Collections</h1> + + + + + + + +<section> + +<header> + + + + + +</header> + +<article> + <div class="container-overview"> + + + <div class="description"><p>A collection of <code>async</code> functions for manipulating collections, such as +arrays and objects.</p></div> + + + + + + + + + + + + + + + + + + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="index.js.html">index.js</a>, <a href="index.js.html#line50">line 50</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + </div> + + + + + + + + + + + + + + + <h3 class="subsection-title">Methods</h3> + + + + + + + <h4 class="name" id="concat"><span class="type-signature">(static) </span>concat<span class="signature">(coll, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import concat from 'async/concat';</code></pre><p>Applies <code>iteratee</code> to each item in <code>coll</code>, concatenating the results. Returns +the concatenated list. The <code>iteratee</code>s are called in parallel, and the +results are concatenated as they return. The results array will be returned in +the original order of <code>coll</code> passed to the <code>iteratee</code> function.</p> +</div> + + + + <dl class="details alias-details"> + <dt class="tag-alias">Alias:</dt> + <dd class="tag-alias"><ul class="dummy"><li>flatMap</li></ul></dd> + </dl> + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>A function to apply to each item in <code>coll</code>, +which should use an array as its result. Invoked with (item, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called after all the +<code>iteratee</code> functions have finished, or an error occurs. Results is an array +containing the concatenated results of the <code>iteratee</code> function. Invoked with +(err, results).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>A Promise, if no callback is passed</p> +</div> + + + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files) { + // files is now a list of filenames that exist in the 3 directories +});</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="concat.js.html">concat.js</a>, <a href="concat.js.html#line4">line 4</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="concatLimit"><span class="type-signature">(static) </span>concatLimit<span class="signature">(coll, limit, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import concatLimit from 'async/concatLimit';</code></pre><p>The same as <a href="#concat"><code>concat</code></a> but runs a maximum of <code>limit</code> async operations at a time.</p> +</div> + + + + <dl class="details alias-details"> + <dt class="tag-alias">Alias:</dt> + <dd class="tag-alias"><ul class="dummy"><li>flatMapLimit</li></ul></dd> + </dl> + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>limit</code></td> + + + <td class="type"> + + +<span class="param-type">number</span> + + + + + + </td> + + + + <td class="description last"><p>The maximum number of async operations at a time.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>A function to apply to each item in <code>coll</code>, +which should use an array as its result. Invoked with (item, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called after all the +<code>iteratee</code> functions have finished, or an error occurs. Results is an array +containing the concatenated results of the <code>iteratee</code> function. Invoked with +(err, results).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>A Promise, if no callback is passed</p> +</div> + + + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="concatLimit.js.html">concatLimit.js</a>, <a href="concatLimit.js.html#line5">line 5</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#concat">async.concat</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="concatSeries"><span class="type-signature">(static) </span>concatSeries<span class="signature">(coll, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import concatSeries from 'async/concatSeries';</code></pre><p>The same as <a href="#concat"><code>concat</code></a> but runs only a single async operation at a time.</p> +</div> + + + + <dl class="details alias-details"> + <dt class="tag-alias">Alias:</dt> + <dd class="tag-alias"><ul class="dummy"><li>flatMapSeries</li></ul></dd> + </dl> + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>A function to apply to each item in <code>coll</code>. +The iteratee should complete with an array an array of results. +Invoked with (item, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called after all the +<code>iteratee</code> functions have finished, or an error occurs. Results is an array +containing the concatenated results of the <code>iteratee</code> function. Invoked with +(err, results).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>A Promise, if no callback is passed</p> +</div> + + + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="concatSeries.js.html">concatSeries.js</a>, <a href="concatSeries.js.html#line4">line 4</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#concat">async.concat</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="detect"><span class="type-signature">(static) </span>detect<span class="signature">(coll, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import detect from 'async/detect';</code></pre><p>Returns the first value in <code>coll</code> that passes an async truth test. The +<code>iteratee</code> is applied in parallel, meaning the first iteratee to return +<code>true</code> will fire the detect <code>callback</code> with that result. That means the +result might not be the first item in the original <code>coll</code> (in terms of order) +that passes the test. +If order within the original <code>coll</code> is important, then look at +<a href="#detectSeries"><code>detectSeries</code></a>.</p> +</div> + + + + <dl class="details alias-details"> + <dt class="tag-alias">Alias:</dt> + <dd class="tag-alias"><ul class="dummy"><li>find</li></ul></dd> + </dl> + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>A truth test to apply to each item in <code>coll</code>. +The iteratee must complete with a boolean value as its result. +Invoked with (item, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called as soon as any +iteratee returns <code>true</code>, or after all the <code>iteratee</code> functions have finished. +Result will be the first item in the array that passes the truth test +(iteratee) or the value <code>undefined</code> if none passed. Invoked with +(err, result).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>A Promise, if no callback is passed</p> +</div> + + + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>async.detect(['file1','file2','file3'], function(filePath, callback) { + fs.access(filePath, function(err) { + callback(null, !err) + }); +}, function(err, result) { + // result now equals the first file in the list that exists +});</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="detect.js.html">detect.js</a>, <a href="detect.js.html#line5">line 5</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="detectLimit"><span class="type-signature">(static) </span>detectLimit<span class="signature">(coll, limit, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import detectLimit from 'async/detectLimit';</code></pre><p>The same as <a href="#detect"><code>detect</code></a> but runs a maximum of <code>limit</code> async operations at a +time.</p> +</div> + + + + <dl class="details alias-details"> + <dt class="tag-alias">Alias:</dt> + <dd class="tag-alias"><ul class="dummy"><li>findLimit</li></ul></dd> + </dl> + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>limit</code></td> + + + <td class="type"> + + +<span class="param-type">number</span> + + + + + + </td> + + + + <td class="description last"><p>The maximum number of async operations at a time.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>A truth test to apply to each item in <code>coll</code>. +The iteratee must complete with a boolean value as its result. +Invoked with (item, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called as soon as any +iteratee returns <code>true</code>, or after all the <code>iteratee</code> functions have finished. +Result will be the first item in the array that passes the truth test +(iteratee) or the value <code>undefined</code> if none passed. Invoked with +(err, result).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a Promise if no callback is passed</p> +</div> + + + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="detectLimit.js.html">detectLimit.js</a>, <a href="detectLimit.js.html#line5">line 5</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#detect">async.detect</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="detectSeries"><span class="type-signature">(static) </span>detectSeries<span class="signature">(coll, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import detectSeries from 'async/detectSeries';</code></pre><p>The same as <a href="#detect"><code>detect</code></a> but runs only a single async operation at a time.</p> +</div> + + + + <dl class="details alias-details"> + <dt class="tag-alias">Alias:</dt> + <dd class="tag-alias"><ul class="dummy"><li>findSeries</li></ul></dd> + </dl> + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>A truth test to apply to each item in <code>coll</code>. +The iteratee must complete with a boolean value as its result. +Invoked with (item, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called as soon as any +iteratee returns <code>true</code>, or after all the <code>iteratee</code> functions have finished. +Result will be the first item in the array that passes the truth test +(iteratee) or the value <code>undefined</code> if none passed. Invoked with +(err, result).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a Promise if no callback is passed</p> +</div> + + + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="detectSeries.js.html">detectSeries.js</a>, <a href="detectSeries.js.html#line5">line 5</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#detect">async.detect</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="each"><span class="type-signature">(static) </span>each<span class="signature">(coll, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import each from 'async/each';</code></pre><p>Applies the function <code>iteratee</code> to each item in <code>coll</code>, in parallel. +The <code>iteratee</code> is called with an item from the list, and a callback for when +it has finished. If the <code>iteratee</code> passes an error to its <code>callback</code>, the +main <code>callback</code> (for the <code>each</code> function) is immediately called with the +error.</p> +<p>Note, that since this function applies <code>iteratee</code> to each item in parallel, +there is no guarantee that the iteratee functions will complete in order.</p> +</div> + + + + <dl class="details alias-details"> + <dt class="tag-alias">Alias:</dt> + <dd class="tag-alias"><ul class="dummy"><li>forEach</li></ul></dd> + </dl> + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>An async function to apply to +each item in <code>coll</code>. Invoked with (item, callback). +The array index is not passed to the iteratee. +If you need the index, use <code>eachOf</code>.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called when all +<code>iteratee</code> functions have finished, or an error occurs. Invoked with (err).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if a callback is omitted</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>// assuming openFiles is an array of file names and saveFile is a function +// to save the modified contents of that file: + +async.each(openFiles, saveFile, function(err){ + // if any of the saves produced an error, err would equal that error +}); + +// assuming openFiles is an array of file names +async.each(openFiles, function(file, callback) { + + // Perform operation on file here. + console.log('Processing file ' + file); + + if( file.length > 32 ) { + console.log('This file name is too long'); + callback('File name too long'); + } else { + // Do work to process file here + console.log('File processed'); + callback(); + } +}, function(err) { + // if any of the file processing produced an error, err would equal that error + if( err ) { + // One of the iterations produced an error. + // All processing will now stop. + console.log('A file failed to process'); + } else { + console.log('All files have been processed successfully'); + } +});</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="each.js.html">each.js</a>, <a href="each.js.html#line6">line 6</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="eachLimit"><span class="type-signature">(static) </span>eachLimit<span class="signature">(coll, limit, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import eachLimit from 'async/eachLimit';</code></pre><p>The same as <a href="#each"><code>each</code></a> but runs a maximum of <code>limit</code> async operations at a time.</p> +</div> + + + + <dl class="details alias-details"> + <dt class="tag-alias">Alias:</dt> + <dd class="tag-alias"><ul class="dummy"><li>forEachLimit</li></ul></dd> + </dl> + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>limit</code></td> + + + <td class="type"> + + +<span class="param-type">number</span> + + + + + + </td> + + + + <td class="description last"><p>The maximum number of async operations at a time.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>An async function to apply to each item in +<code>coll</code>. +The array index is not passed to the iteratee. +If you need the index, use <code>eachOfLimit</code>. +Invoked with (item, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called when all +<code>iteratee</code> functions have finished, or an error occurs. Invoked with (err).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if a callback is omitted</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="eachLimit.js.html">eachLimit.js</a>, <a href="eachLimit.js.html#line6">line 6</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#each">async.each</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="eachOf"><span class="type-signature">(static) </span>eachOf<span class="signature">(coll, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import eachOf from 'async/eachOf';</code></pre><p>Like <a href="#each"><code>each</code></a>, except that it passes the key (or index) as the second argument +to the iteratee.</p> +</div> + + + + <dl class="details alias-details"> + <dt class="tag-alias">Alias:</dt> + <dd class="tag-alias"><ul class="dummy"><li>forEachOf</li></ul></dd> + </dl> + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>A function to apply to each +item in <code>coll</code>. +The <code>key</code> is the item's key, or index in the case of an array. +Invoked with (item, key, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called when all +<code>iteratee</code> functions have finished, or an error occurs. Invoked with (err).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if a callback is omitted</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"}; +var configs = {}; + +async.forEachOf(obj, function (value, key, callback) { + fs.readFile(__dirname + value, "utf8", function (err, data) { + if (err) return callback(err); + try { + configs[key] = JSON.parse(data); + } catch (e) { + return callback(e); + } + callback(); + }); +}, function (err) { + if (err) console.error(err.message); + // configs is now a map of JSON data + doSomethingWith(configs); +});</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="eachOf.js.html">eachOf.js</a>, <a href="eachOf.js.html#line42">line 42</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#each">async.each</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="eachOfLimit"><span class="type-signature">(static) </span>eachOfLimit<span class="signature">(coll, limit, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import eachOfLimit from 'async/eachOfLimit';</code></pre><p>The same as <a href="#eachOf"><code>eachOf</code></a> but runs a maximum of <code>limit</code> async operations at a +time.</p> +</div> + + + + <dl class="details alias-details"> + <dt class="tag-alias">Alias:</dt> + <dd class="tag-alias"><ul class="dummy"><li>forEachOfLimit</li></ul></dd> + </dl> + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>limit</code></td> + + + <td class="type"> + + +<span class="param-type">number</span> + + + + + + </td> + + + + <td class="description last"><p>The maximum number of async operations at a time.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>An async function to apply to each +item in <code>coll</code>. The <code>key</code> is the item's key, or index in the case of an +array. +Invoked with (item, key, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called when all +<code>iteratee</code> functions have finished, or an error occurs. Invoked with (err).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if a callback is omitted</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="eachOfLimit.js.html">eachOfLimit.js</a>, <a href="eachOfLimit.js.html#line5">line 5</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#eachOf">async.eachOf</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="eachOfSeries"><span class="type-signature">(static) </span>eachOfSeries<span class="signature">(coll, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import eachOfSeries from 'async/eachOfSeries';</code></pre><p>The same as <a href="#eachOf"><code>eachOf</code></a> but runs only a single async operation at a time.</p> +</div> + + + + <dl class="details alias-details"> + <dt class="tag-alias">Alias:</dt> + <dd class="tag-alias"><ul class="dummy"><li>forEachOfSeries</li></ul></dd> + </dl> + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>An async function to apply to each item in +<code>coll</code>. +Invoked with (item, key, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called when all <code>iteratee</code> +functions have finished, or an error occurs. Invoked with (err).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if a callback is omitted</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="eachOfSeries.js.html">eachOfSeries.js</a>, <a href="eachOfSeries.js.html#line4">line 4</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#eachOf">async.eachOf</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="eachSeries"><span class="type-signature">(static) </span>eachSeries<span class="signature">(coll, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import eachSeries from 'async/eachSeries';</code></pre><p>The same as <a href="#each"><code>each</code></a> but runs only a single async operation at a time.</p> +<p>Note, that unlike <a href="#each"><code>each</code></a>, this function applies iteratee to each item +in series and therefore the iteratee functions will complete in order.</p> +</div> + + + + <dl class="details alias-details"> + <dt class="tag-alias">Alias:</dt> + <dd class="tag-alias"><ul class="dummy"><li>forEachSeries</li></ul></dd> + </dl> + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>An async function to apply to each +item in <code>coll</code>. +The array index is not passed to the iteratee. +If you need the index, use <code>eachOfSeries</code>. +Invoked with (item, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called when all +<code>iteratee</code> functions have finished, or an error occurs. Invoked with (err).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if a callback is omitted</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="eachSeries.js.html">eachSeries.js</a>, <a href="eachSeries.js.html#line4">line 4</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#each">async.each</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="every"><span class="type-signature">(static) </span>every<span class="signature">(coll, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import every from 'async/every';</code></pre><p>Returns <code>true</code> if every element in <code>coll</code> satisfies an async test. If any +iteratee call returns <code>false</code>, the main <code>callback</code> is immediately called.</p> +</div> + + + + <dl class="details alias-details"> + <dt class="tag-alias">Alias:</dt> + <dd class="tag-alias"><ul class="dummy"><li>all</li></ul></dd> + </dl> + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>An async truth test to apply to each item +in the collection in parallel. +The iteratee must complete with a boolean result value. +Invoked with (item, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called after all the +<code>iteratee</code> functions have finished. Result will be either <code>true</code> or <code>false</code> +depending on the values of the async tests. Invoked with (err, result).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback provided</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>async.every(['file1','file2','file3'], function(filePath, callback) { + fs.access(filePath, function(err) { + callback(null, !err) + }); +}, function(err, result) { + // if result is true then every file exists +});</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="every.js.html">every.js</a>, <a href="every.js.html#line5">line 5</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="everyLimit"><span class="type-signature">(static) </span>everyLimit<span class="signature">(coll, limit, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import everyLimit from 'async/everyLimit';</code></pre><p>The same as <a href="#every"><code>every</code></a> but runs a maximum of <code>limit</code> async operations at a time.</p> +</div> + + + + <dl class="details alias-details"> + <dt class="tag-alias">Alias:</dt> + <dd class="tag-alias"><ul class="dummy"><li>allLimit</li></ul></dd> + </dl> + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>limit</code></td> + + + <td class="type"> + + +<span class="param-type">number</span> + + + + + + </td> + + + + <td class="description last"><p>The maximum number of async operations at a time.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>An async truth test to apply to each item +in the collection in parallel. +The iteratee must complete with a boolean result value. +Invoked with (item, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called after all the +<code>iteratee</code> functions have finished. Result will be either <code>true</code> or <code>false</code> +depending on the values of the async tests. Invoked with (err, result).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback provided</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="everyLimit.js.html">everyLimit.js</a>, <a href="everyLimit.js.html#line5">line 5</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#every">async.every</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="everySeries"><span class="type-signature">(static) </span>everySeries<span class="signature">(coll, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import everySeries from 'async/everySeries';</code></pre><p>The same as <a href="#every"><code>every</code></a> but runs only a single async operation at a time.</p> +</div> + + + + <dl class="details alias-details"> + <dt class="tag-alias">Alias:</dt> + <dd class="tag-alias"><ul class="dummy"><li>allSeries</li></ul></dd> + </dl> + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>An async truth test to apply to each item +in the collection in series. +The iteratee must complete with a boolean result value. +Invoked with (item, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called after all the +<code>iteratee</code> functions have finished. Result will be either <code>true</code> or <code>false</code> +depending on the values of the async tests. Invoked with (err, result).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback provided</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="everySeries.js.html">everySeries.js</a>, <a href="everySeries.js.html#line5">line 5</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#every">async.every</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="filter"><span class="type-signature">(static) </span>filter<span class="signature">(coll, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import filter from 'async/filter';</code></pre><p>Returns a new array of all the values in <code>coll</code> which pass an async truth +test. This operation is performed in parallel, but the results array will be +in the same order as the original.</p> +</div> + + + + <dl class="details alias-details"> + <dt class="tag-alias">Alias:</dt> + <dd class="tag-alias"><ul class="dummy"><li>select</li></ul></dd> + </dl> + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + </td> + + + + <td class="description last"><p>A truth test to apply to each item in <code>coll</code>. +The <code>iteratee</code> is passed a <code>callback(err, truthValue)</code>, which must be called +with a boolean argument once it has completed. Invoked with (item, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called after all the +<code>iteratee</code> functions have finished. Invoked with (err, results).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback provided</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>async.filter(['file1','file2','file3'], function(filePath, callback) { + fs.access(filePath, function(err) { + callback(null, !err) + }); +}, function(err, results) { + // results now equals an array of the existing files +});</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="filter.js.html">filter.js</a>, <a href="filter.js.html#line5">line 5</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="filterLimit"><span class="type-signature">(static) </span>filterLimit<span class="signature">(coll, limit, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import filterLimit from 'async/filterLimit';</code></pre><p>The same as <a href="#filter"><code>filter</code></a> but runs a maximum of <code>limit</code> async operations at a +time.</p> +</div> + + + + <dl class="details alias-details"> + <dt class="tag-alias">Alias:</dt> + <dd class="tag-alias"><ul class="dummy"><li>selectLimit</li></ul></dd> + </dl> + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>limit</code></td> + + + <td class="type"> + + +<span class="param-type">number</span> + + + + + + </td> + + + + <td class="description last"><p>The maximum number of async operations at a time.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + </td> + + + + <td class="description last"><p>A truth test to apply to each item in <code>coll</code>. +The <code>iteratee</code> is passed a <code>callback(err, truthValue)</code>, which must be called +with a boolean argument once it has completed. Invoked with (item, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called after all the +<code>iteratee</code> functions have finished. Invoked with (err, results).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback provided</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="filterLimit.js.html">filterLimit.js</a>, <a href="filterLimit.js.html#line5">line 5</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#filter">async.filter</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="filterSeries"><span class="type-signature">(static) </span>filterSeries<span class="signature">(coll, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import filterSeries from 'async/filterSeries';</code></pre><p>The same as <a href="#filter"><code>filter</code></a> but runs only a single async operation at a time.</p> +</div> + + + + <dl class="details alias-details"> + <dt class="tag-alias">Alias:</dt> + <dd class="tag-alias"><ul class="dummy"><li>selectSeries</li></ul></dd> + </dl> + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + </td> + + + + <td class="description last"><p>A truth test to apply to each item in <code>coll</code>. +The <code>iteratee</code> is passed a <code>callback(err, truthValue)</code>, which must be called +with a boolean argument once it has completed. Invoked with (item, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called after all the +<code>iteratee</code> functions have finished. Invoked with (err, results)</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback provided</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="filterSeries.js.html">filterSeries.js</a>, <a href="filterSeries.js.html#line5">line 5</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#filter">async.filter</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="groupBy"><span class="type-signature">(static) </span>groupBy<span class="signature">(coll, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import groupBy from 'async/groupBy';</code></pre><p>Returns a new object, where each value corresponds to an array of items, from +<code>coll</code>, that returned the corresponding key. That is, the keys of the object +correspond to the values passed to the <code>iteratee</code> callback.</p> +<p>Note: Since this function applies the <code>iteratee</code> to each item in parallel, +there is no guarantee that the <code>iteratee</code> functions will complete in order. +However, the values for each key in the <code>result</code> will be in the same order as +the original <code>coll</code>. For Objects, the values will roughly be in the order of +the original Objects' keys (but this can vary across JavaScript engines).</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>An async function to apply to each item in +<code>coll</code>. +The iteratee should complete with a <code>key</code> to group the value under. +Invoked with (value, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called when all <code>iteratee</code> +functions have finished, or an error occurs. Result is an <code>Object</code> whoses +properties are arrays of values which returned the corresponding key.</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback is passed</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>async.groupBy(['userId1', 'userId2', 'userId3'], function(userId, callback) { + db.findById(userId, function(err, user) { + if (err) return callback(err); + return callback(null, user.age); + }); +}, function(err, result) { + // result is object containing the userIds grouped by age + // e.g. { 30: ['userId1', 'userId3'], 42: ['userId2']}; +});</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="groupBy.js.html">groupBy.js</a>, <a href="groupBy.js.html#line3">line 3</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="groupByLimit"><span class="type-signature">(static) </span>groupByLimit<span class="signature">(coll, limit, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import groupByLimit from 'async/groupByLimit';</code></pre><p>The same as <a href="#groupBy"><code>groupBy</code></a> but runs a maximum of <code>limit</code> async operations at a time.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>limit</code></td> + + + <td class="type"> + + +<span class="param-type">number</span> + + + + + + </td> + + + + <td class="description last"><p>The maximum number of async operations at a time.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>An async function to apply to each item in +<code>coll</code>. +The iteratee should complete with a <code>key</code> to group the value under. +Invoked with (value, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called when all <code>iteratee</code> +functions have finished, or an error occurs. Result is an <code>Object</code> whoses +properties are arrays of values which returned the corresponding key.</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback is passed</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="groupByLimit.js.html">groupByLimit.js</a>, <a href="groupByLimit.js.html#line5">line 5</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#groupBy">async.groupBy</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="groupBySeries"><span class="type-signature">(static) </span>groupBySeries<span class="signature">(coll, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import groupBySeries from 'async/groupBySeries';</code></pre><p>The same as <a href="#groupBy"><code>groupBy</code></a> but runs only a single async operation at a time.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>An async function to apply to each item in +<code>coll</code>. +The iteratee should complete with a <code>key</code> to group the value under. +Invoked with (value, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called when all <code>iteratee</code> +functions have finished, or an error occurs. Result is an <code>Object</code> whoses +properties are arrays of values which returned the corresponding key.</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback is passed</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="groupBySeries.js.html">groupBySeries.js</a>, <a href="groupBySeries.js.html#line3">line 3</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#groupBy">async.groupBy</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="map"><span class="type-signature">(static) </span>map<span class="signature">(coll, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import map from 'async/map';</code></pre><p>Produces a new collection of values by mapping each value in <code>coll</code> through +the <code>iteratee</code> function. The <code>iteratee</code> is called with an item from <code>coll</code> +and a callback for when it has finished processing. Each of these callback +takes 2 arguments: an <code>error</code>, and the transformed item from <code>coll</code>. If +<code>iteratee</code> passes an error to its callback, the main <code>callback</code> (for the +<code>map</code> function) is immediately called with the error.</p> +<p>Note, that since this function applies the <code>iteratee</code> to each item in +parallel, there is no guarantee that the <code>iteratee</code> functions will complete +in order. However, the results array will be in the same order as the +original <code>coll</code>.</p> +<p>If <code>map</code> is passed an Object, the results will be an Array. The results +will roughly be in the order of the original Objects' keys (but this can +vary across JavaScript engines).</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>An async function to apply to each item in +<code>coll</code>. +The iteratee should complete with the transformed item. +Invoked with (item, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called when all <code>iteratee</code> +functions have finished, or an error occurs. Results is an Array of the +transformed items from the <code>coll</code>. Invoked with (err, results).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback is passed</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>async.map(['file1','file2','file3'], fs.stat, function(err, results) { + // results is now an array of stats for each file +});</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="map.js.html">map.js</a>, <a href="map.js.html#line5">line 5</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="mapLimit"><span class="type-signature">(static) </span>mapLimit<span class="signature">(coll, limit, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import mapLimit from 'async/mapLimit';</code></pre><p>The same as <a href="#map"><code>map</code></a> but runs a maximum of <code>limit</code> async operations at a time.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>limit</code></td> + + + <td class="type"> + + +<span class="param-type">number</span> + + + + + + </td> + + + + <td class="description last"><p>The maximum number of async operations at a time.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>An async function to apply to each item in +<code>coll</code>. +The iteratee should complete with the transformed item. +Invoked with (item, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called when all <code>iteratee</code> +functions have finished, or an error occurs. Results is an array of the +transformed items from the <code>coll</code>. Invoked with (err, results).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback is passed</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="mapLimit.js.html">mapLimit.js</a>, <a href="mapLimit.js.html#line5">line 5</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#map">async.map</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="mapSeries"><span class="type-signature">(static) </span>mapSeries<span class="signature">(coll, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import mapSeries from 'async/mapSeries';</code></pre><p>The same as <a href="#map"><code>map</code></a> but runs only a single async operation at a time.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>An async function to apply to each item in +<code>coll</code>. +The iteratee should complete with the transformed item. +Invoked with (item, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called when all <code>iteratee</code> +functions have finished, or an error occurs. Results is an array of the +transformed items from the <code>coll</code>. Invoked with (err, results).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback is passed</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="mapSeries.js.html">mapSeries.js</a>, <a href="mapSeries.js.html#line5">line 5</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#map">async.map</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="mapValues"><span class="type-signature">(static) </span>mapValues<span class="signature">(obj, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import mapValues from 'async/mapValues';</code></pre><p>A relative of <a href="#map"><code>map</code></a>, designed for use with objects.</p> +<p>Produces a new Object by mapping each value of <code>obj</code> through the <code>iteratee</code> +function. The <code>iteratee</code> is called each <code>value</code> and <code>key</code> from <code>obj</code> and a +callback for when it has finished processing. Each of these callbacks takes +two arguments: an <code>error</code>, and the transformed item from <code>obj</code>. If <code>iteratee</code> +passes an error to its callback, the main <code>callback</code> (for the <code>mapValues</code> +function) is immediately called with the error.</p> +<p>Note, the order of the keys in the result is not guaranteed. The keys will +be roughly in the order they complete, (but this is very engine-specific)</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>obj</code></td> + + + <td class="type"> + + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>A function to apply to each value and key +in <code>coll</code>. +The iteratee should complete with the transformed value as its result. +Invoked with (value, key, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called when all <code>iteratee</code> +functions have finished, or an error occurs. <code>result</code> is a new object consisting +of each key from <code>obj</code>, with each transformed value on the right-hand side. +Invoked with (err, result).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback is passed</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>async.mapValues({ + f1: 'file1', + f2: 'file2', + f3: 'file3' +}, function (file, key, callback) { + fs.stat(file, callback); +}, function(err, result) { + // result is now a map of stats for each file, e.g. + // { + // f1: [stats for file1], + // f2: [stats for file2], + // f3: [stats for file3] + // } +});</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="mapValues.js.html">mapValues.js</a>, <a href="mapValues.js.html#line3">line 3</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="mapValuesLimit"><span class="type-signature">(static) </span>mapValuesLimit<span class="signature">(obj, limit, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import mapValuesLimit from 'async/mapValuesLimit';</code></pre><p>The same as <a href="#mapValues"><code>mapValues</code></a> but runs a maximum of <code>limit</code> async operations at a +time.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>obj</code></td> + + + <td class="type"> + + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>limit</code></td> + + + <td class="type"> + + +<span class="param-type">number</span> + + + + + + </td> + + + + <td class="description last"><p>The maximum number of async operations at a time.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>A function to apply to each value and key +in <code>coll</code>. +The iteratee should complete with the transformed value as its result. +Invoked with (value, key, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called when all <code>iteratee</code> +functions have finished, or an error occurs. <code>result</code> is a new object consisting +of each key from <code>obj</code>, with each transformed value on the right-hand side. +Invoked with (err, result).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback is passed</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="mapValuesLimit.js.html">mapValuesLimit.js</a>, <a href="mapValuesLimit.js.html#line6">line 6</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#mapValues">async.mapValues</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="mapValuesSeries"><span class="type-signature">(static) </span>mapValuesSeries<span class="signature">(obj, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import mapValuesSeries from 'async/mapValuesSeries';</code></pre><p>The same as <a href="#mapValues"><code>mapValues</code></a> but runs only a single async operation at a time.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>obj</code></td> + + + <td class="type"> + + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>A function to apply to each value and key +in <code>coll</code>. +The iteratee should complete with the transformed value as its result. +Invoked with (value, key, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called when all <code>iteratee</code> +functions have finished, or an error occurs. <code>result</code> is a new object consisting +of each key from <code>obj</code>, with each transformed value on the right-hand side. +Invoked with (err, result).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback is passed</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="mapValuesSeries.js.html">mapValuesSeries.js</a>, <a href="mapValuesSeries.js.html#line3">line 3</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#mapValues">async.mapValues</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="reduce"><span class="type-signature">(static) </span>reduce<span class="signature">(coll, memo, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import reduce from 'async/reduce';</code></pre><p>Reduces <code>coll</code> into a single value using an async <code>iteratee</code> to return each +successive step. <code>memo</code> is the initial state of the reduction. This function +only operates in series.</p> +<p>For performance reasons, it may make sense to split a call to this function +into a parallel map, and then use the normal <code>Array.prototype.reduce</code> on the +results. This function is for situations where each step in the reduction +needs to be async; if you can get the data before reducing it, then it's +probably a good idea to do so.</p> +</div> + + + + <dl class="details alias-details"> + <dt class="tag-alias">Alias:</dt> + <dd class="tag-alias"><ul class="dummy"><li>foldl</li></ul></dd> + </dl> + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>memo</code></td> + + + <td class="type"> + + +<span class="param-type">*</span> + + + + + + </td> + + + + <td class="description last"><p>The initial state of the reduction.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>A function applied to each item in the +array to produce the next step in the reduction. +The <code>iteratee</code> should complete with the next state of the reduction. +If the iteratee complete with an error, the reduction is stopped and the +main <code>callback</code> is immediately called with the error. +Invoked with (memo, item, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called after all the +<code>iteratee</code> functions have finished. Result is the reduced value. Invoked with +(err, result).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback is passed</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>async.reduce([1,2,3], 0, function(memo, item, callback) { + // pointless async: + process.nextTick(function() { + callback(null, memo + item) + }); +}, function(err, result) { + // result is now equal to the last value of memo, which is 6 +});</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="reduce.js.html">reduce.js</a>, <a href="reduce.js.html#line6">line 6</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="reduceRight"><span class="type-signature">(static) </span>reduceRight<span class="signature">(array, memo, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import reduceRight from 'async/reduceRight';</code></pre><p>Same as <a href="#reduce"><code>reduce</code></a>, only operates on <code>array</code> in reverse order.</p> +</div> + + + + <dl class="details alias-details"> + <dt class="tag-alias">Alias:</dt> + <dd class="tag-alias"><ul class="dummy"><li>foldr</li></ul></dd> + </dl> + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>array</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>memo</code></td> + + + <td class="type"> + + +<span class="param-type">*</span> + + + + + + </td> + + + + <td class="description last"><p>The initial state of the reduction.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>A function applied to each item in the +array to produce the next step in the reduction. +The <code>iteratee</code> should complete with the next state of the reduction. +If the iteratee complete with an error, the reduction is stopped and the +main <code>callback</code> is immediately called with the error. +Invoked with (memo, item, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called after all the +<code>iteratee</code> functions have finished. Result is the reduced value. Invoked with +(err, result).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback is passed</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="reduceRight.js.html">reduceRight.js</a>, <a href="reduceRight.js.html#line3">line 3</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#reduce">async.reduce</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="reject"><span class="type-signature">(static) </span>reject<span class="signature">(coll, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import reject from 'async/reject';</code></pre><p>The opposite of <a href="#filter"><code>filter</code></a>. Removes values that pass an <code>async</code> truth test.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + </td> + + + + <td class="description last"><p>An async truth test to apply to each item in +<code>coll</code>. +The should complete with a boolean value as its <code>result</code>. +Invoked with (item, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called after all the +<code>iteratee</code> functions have finished. Invoked with (err, results).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback is passed</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>async.reject(['file1','file2','file3'], function(filePath, callback) { + fs.access(filePath, function(err) { + callback(null, !err) + }); +}, function(err, results) { + // results now equals an array of missing files + createFiles(results); +});</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="reject.js.html">reject.js</a>, <a href="reject.js.html#line5">line 5</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#filter">async.filter</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="rejectLimit"><span class="type-signature">(static) </span>rejectLimit<span class="signature">(coll, limit, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import rejectLimit from 'async/rejectLimit';</code></pre><p>The same as <a href="#reject"><code>reject</code></a> but runs a maximum of <code>limit</code> async operations at a +time.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>limit</code></td> + + + <td class="type"> + + +<span class="param-type">number</span> + + + + + + </td> + + + + <td class="description last"><p>The maximum number of async operations at a time.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + </td> + + + + <td class="description last"><p>An async truth test to apply to each item in +<code>coll</code>. +The should complete with a boolean value as its <code>result</code>. +Invoked with (item, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called after all the +<code>iteratee</code> functions have finished. Invoked with (err, results).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback is passed</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="rejectLimit.js.html">rejectLimit.js</a>, <a href="rejectLimit.js.html#line4">line 4</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#reject">async.reject</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="rejectSeries"><span class="type-signature">(static) </span>rejectSeries<span class="signature">(coll, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import rejectSeries from 'async/rejectSeries';</code></pre><p>The same as <a href="#reject"><code>reject</code></a> but runs only a single async operation at a time.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + </td> + + + + <td class="description last"><p>An async truth test to apply to each item in +<code>coll</code>. +The should complete with a boolean value as its <code>result</code>. +Invoked with (item, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called after all the +<code>iteratee</code> functions have finished. Invoked with (err, results).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback is passed</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="rejectSeries.js.html">rejectSeries.js</a>, <a href="rejectSeries.js.html#line5">line 5</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#reject">async.reject</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="some"><span class="type-signature">(static) </span>some<span class="signature">(coll, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import some from 'async/some';</code></pre><p>Returns <code>true</code> if at least one element in the <code>coll</code> satisfies an async test. +If any iteratee call returns <code>true</code>, the main <code>callback</code> is immediately +called.</p> +</div> + + + + <dl class="details alias-details"> + <dt class="tag-alias">Alias:</dt> + <dd class="tag-alias"><ul class="dummy"><li>any</li></ul></dd> + </dl> + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>An async truth test to apply to each item +in the collections in parallel. +The iteratee should complete with a boolean <code>result</code> value. +Invoked with (item, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called as soon as any +iteratee returns <code>true</code>, or after all the iteratee functions have finished. +Result will be either <code>true</code> or <code>false</code> depending on the values of the async +tests. Invoked with (err, result).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback provided</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>async.some(['file1','file2','file3'], function(filePath, callback) { + fs.access(filePath, function(err) { + callback(null, !err) + }); +}, function(err, result) { + // if result is true then at least one of the files exists +});</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="some.js.html">some.js</a>, <a href="some.js.html#line5">line 5</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="someLimit"><span class="type-signature">(static) </span>someLimit<span class="signature">(coll, limit, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import someLimit from 'async/someLimit';</code></pre><p>The same as <a href="#some"><code>some</code></a> but runs a maximum of <code>limit</code> async operations at a time.</p> +</div> + + + + <dl class="details alias-details"> + <dt class="tag-alias">Alias:</dt> + <dd class="tag-alias"><ul class="dummy"><li>anyLimit</li></ul></dd> + </dl> + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>limit</code></td> + + + <td class="type"> + + +<span class="param-type">number</span> + + + + + + </td> + + + + <td class="description last"><p>The maximum number of async operations at a time.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>An async truth test to apply to each item +in the collections in parallel. +The iteratee should complete with a boolean <code>result</code> value. +Invoked with (item, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called as soon as any +iteratee returns <code>true</code>, or after all the iteratee functions have finished. +Result will be either <code>true</code> or <code>false</code> depending on the values of the async +tests. Invoked with (err, result).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback provided</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="someLimit.js.html">someLimit.js</a>, <a href="someLimit.js.html#line5">line 5</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#some">async.some</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="someSeries"><span class="type-signature">(static) </span>someSeries<span class="signature">(coll, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import someSeries from 'async/someSeries';</code></pre><p>The same as <a href="#some"><code>some</code></a> but runs only a single async operation at a time.</p> +</div> + + + + <dl class="details alias-details"> + <dt class="tag-alias">Alias:</dt> + <dd class="tag-alias"><ul class="dummy"><li>anySeries</li></ul></dd> + </dl> + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>An async truth test to apply to each item +in the collections in series. +The iteratee should complete with a boolean <code>result</code> value. +Invoked with (item, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called as soon as any +iteratee returns <code>true</code>, or after all the iteratee functions have finished. +Result will be either <code>true</code> or <code>false</code> depending on the values of the async +tests. Invoked with (err, result).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback provided</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="someSeries.js.html">someSeries.js</a>, <a href="someSeries.js.html#line5">line 5</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#some">async.some</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="sortBy"><span class="type-signature">(static) </span>sortBy<span class="signature">(coll, iteratee, callback)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import sortBy from 'async/sortBy';</code></pre><p>Sorts a list by the results of running each <code>coll</code> value through an async +<code>iteratee</code>.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>An async function to apply to each item in +<code>coll</code>. +The iteratee should complete with a value to use as the sort criteria as +its <code>result</code>. +Invoked with (item, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + </td> + + + + <td class="description last"><p>A callback which is called after all the +<code>iteratee</code> functions have finished, or an error occurs. Results is the items +from the original <code>coll</code> sorted by the values returned by the <code>iteratee</code> +calls. Invoked with (err, results).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback passed</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>async.sortBy(['file1','file2','file3'], function(file, callback) { + fs.stat(file, function(err, stats) { + callback(err, stats.mtime); + }); +}, function(err, results) { + // results is now the original array of files sorted by + // modified date +}); + +// By modifying the callback parameter the +// sorting order can be influenced: + +// ascending order +async.sortBy([1,9,3,5], function(x, callback) { + callback(null, x); +}, function(err,result) { + // result callback +}); + +// descending order +async.sortBy([1,9,3,5], function(x, callback) { + callback(null, x*-1); //<- x*-1 instead of x, turns the order around +}, function(err,result) { + // result callback +});</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="sortBy.js.html">sortBy.js</a>, <a href="sortBy.js.html#line5">line 5</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="transform"><span class="type-signature">(static) </span>transform<span class="signature">(coll, accumulator<span class="signature-attributes">opt</span>, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import transform from 'async/transform';</code></pre><p>A relative of <code>reduce</code>. Takes an Object or Array, and iterates over each +element in parallel, each step potentially mutating an <code>accumulator</code> value. +The type of the accumulator defaults to the type of collection passed in.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>coll</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection to iterate over.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>accumulator</code></td> + + + <td class="type"> + + +<span class="param-type">*</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>The initial state of the transform. If omitted, +it will default to an empty Object or Array, depending on the type of <code>coll</code></p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>A function applied to each item in the +collection that potentially modifies the accumulator. +Invoked with (accumulator, item, key, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called after all the +<code>iteratee</code> functions have finished. Result is the transformed accumulator. +Invoked with (err, result).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback provided</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + <h5>Examples</h5> + + <pre class="prettyprint"><code>async.transform([1,2,3], function(acc, item, index, callback) { + // pointless async: + process.nextTick(function() { + acc[index] = item * 2 + callback(null) + }); +}, function(err, result) { + // result is now equal to [2, 4, 6] +});</code></pre> + + <pre class="prettyprint"><code>async.transform({a: 1, b: 2, c: 3}, function (obj, val, key, callback) { + setImmediate(function () { + obj[key] = val * 2; + callback(); + }) +}, function (err, result) { + // result is equal to {a: 2, b: 4, c: 6} +})</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="transform.js.html">transform.js</a>, <a href="transform.js.html#line6">line 6</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + + +</article> + +</section> + + + + + + + <h1 class="page-title" id="controlflow">Control Flow</h1> + + + + + + + +<section> + +<header> + + + + + +</header> + +<article> + <div class="container-overview"> + + + <div class="description"><p>A collection of <code>async</code> functions for controlling the flow through a script.</p></div> + + + + + + + + + + + + + + + + + + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="index.js.html">index.js</a>, <a href="index.js.html#line56">line 56</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + </div> + + + + + + + + + + + + + + + <h3 class="subsection-title">Methods</h3> + + + + + + + <h4 class="name" id="applyEach"><span class="type-signature">(static) </span>applyEach<span class="signature">(fns, …args<span class="signature-attributes">opt</span>, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {function}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import applyEach from 'async/applyEach';</code></pre><p>Applies the provided arguments to each function in the array, calling +<code>callback</code> after all functions have completed. If you only provide the first +argument, <code>fns</code>, then it will return a function which lets you pass in the +arguments as if it were a single function call. If more arguments are +provided, <code>callback</code> is required while <code>args</code> is still optional. The results +for each of the applied async functions are passed to the final callback +as an array.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>fns</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection of <a href="global.html">AsyncFunction</a>s +to all call with the same arguments</p></td> + </tr> + + + + <tr> + + <td class="name"><code>args</code></td> + + + <td class="type"> + + +<span class="param-type">*</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>any number of separate arguments to pass to the +function.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>the final argument should be the callback, +called when all functions have completed processing.</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <ul> +<li>If only the first argument, <code>fns</code>, is provided, it will +return a function which lets you pass in the arguments as if it were a single +function call. The signature is <code>(..args, callback)</code>. If invoked with any +arguments, <code>callback</code> is required.</li> +</ul> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">function</span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>async.applyEach([enableSearch, updateSchema], 'bucket', (err, results) => { + // results[0] is the results for `enableSearch` + // results[1] is the results for `updateSchema` +}); + +// partial application example: +async.each( + buckets, + async.applyEach([enableSearch, updateSchema]), + callback +);</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="applyEach.js.html">applyEach.js</a>, <a href="applyEach.js.html#line4">line 4</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="applyEachSeries"><span class="type-signature">(static) </span>applyEachSeries<span class="signature">(fns, …args<span class="signature-attributes">opt</span>, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {function}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import applyEachSeries from 'async/applyEachSeries';</code></pre><p>The same as <a href="#applyEach"><code>applyEach</code></a> but runs only a single async operation at a time.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>fns</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection of <a href="global.html">AsyncFunction</a>s to all +call with the same arguments</p></td> + </tr> + + + + <tr> + + <td class="name"><code>args</code></td> + + + <td class="type"> + + +<span class="param-type">*</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>any number of separate arguments to pass to the +function.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>the final argument should be the callback, +called when all functions have completed processing.</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <ul> +<li>If only the first argument is provided, it will return +a function which lets you pass in the arguments as if it were a single +function call.</li> +</ul> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">function</span> + + + </dd> +</dl> + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="applyEachSeries.js.html">applyEachSeries.js</a>, <a href="applyEachSeries.js.html#line4">line 4</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#applyEach">async.applyEach</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="auto"><span class="type-signature">(static) </span>auto<span class="signature">(tasks, concurrency<span class="signature-attributes">opt</span>, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import auto from 'async/auto';</code></pre><p>Determines the best order for running the <a href="global.html">AsyncFunction</a>s in <code>tasks</code>, based on +their requirements. Each function can optionally depend on other functions +being completed first, and each function is run as soon as its requirements +are satisfied.</p> +<p>If any of the <a href="global.html">AsyncFunction</a>s pass an error to their callback, the <code>auto</code> sequence +will stop. Further tasks will not execute (so any other functions depending +on it will not run), and the main <code>callback</code> is immediately called with the +error.</p> +<p><a href="global.html">AsyncFunction</a>s also receive an object containing the results of functions which +have completed so far as the first argument, if they have dependencies. If a +task function has no dependencies, it will only be passed a callback.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + <th>Default</th> + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>tasks</code></td> + + + <td class="type"> + + +<span class="param-type">Object</span> + + + + + + </td> + + + <td class="default"> + + </td> + + + <td class="description last"><p>An object. Each of its properties is either a +function or an array of requirements, with the <a href="global.html">AsyncFunction</a> itself the last item +in the array. The object's key of a property serves as the name of the task +defined by that property, i.e. can be used when specifying requirements for +other tasks. The function receives one or two arguments:</p> +<ul> +<li>a <code>results</code> object, containing the results of the previously executed +functions, only passed if the task has any dependencies,</li> +<li>a <code>callback(err, result)</code> function, which must be called when finished, +passing an <code>error</code> (which can be <code>null</code>) and the result of the function's +execution.</li> +</ul></td> + </tr> + + + + <tr> + + <td class="name"><code>concurrency</code></td> + + + <td class="type"> + + +<span class="param-type">number</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + <td class="default"> + + Infinity + + </td> + + + <td class="description last"><p>An optional <code>integer</code> for +determining the maximum number of tasks that can be run in parallel. By +default, as many as possible.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + <td class="default"> + + </td> + + + <td class="description last"><p>An optional callback which is called when all +the tasks have been completed. It receives the <code>err</code> argument if any <code>tasks</code> +pass an error to their callback. Results are always returned; however, if an +error occurs, no further <code>tasks</code> will be performed, and the results object +will only contain partial results. Invoked with (err, results).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if a callback is not passed</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>async.auto({ + // this function will just be passed a callback + readData: async.apply(fs.readFile, 'data.txt', 'utf-8'), + showData: ['readData', function(results, cb) { + // results.readData is the file's contents + // ... + }] +}, callback); + +async.auto({ + get_data: function(callback) { + console.log('in get_data'); + // async code to get some data + callback(null, 'data', 'converted to array'); + }, + make_folder: function(callback) { + console.log('in make_folder'); + // async code to create a directory to store a file in + // this is run at the same time as getting the data + callback(null, 'folder'); + }, + write_file: ['get_data', 'make_folder', function(results, callback) { + console.log('in write_file', JSON.stringify(results)); + // once there is some data and the directory exists, + // write the data to a file in the directory + callback(null, 'filename'); + }], + email_link: ['write_file', function(results, callback) { + console.log('in email_link', JSON.stringify(results)); + // once the file is written let's email a link to it... + // results.write_file contains the filename returned by write_file. + callback(null, {'file':results.write_file, 'email':'user@example.com'}); + }] +}, function(err, results) { + console.log('err = ', err); + console.log('results = ', results); +});</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="auto.js.html">auto.js</a>, <a href="auto.js.html#line6">line 6</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="autoInject"><span class="type-signature">(static) </span>autoInject<span class="signature">(tasks, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import autoInject from 'async/autoInject';</code></pre><p>A dependency-injected version of the <a href="#auto">async.auto</a> function. Dependent +tasks are specified as parameters to the function, after the usual callback +parameter, with the parameter names matching the names of the tasks it +depends on. This can provide even more readable task graphs which can be +easier to maintain.</p> +<p>If a final callback is specified, the task results are similarly injected, +specified as named parameters after the initial error parameter.</p> +<p>The autoInject function is purely syntactic sugar and its semantics are +otherwise equivalent to <a href="#auto">async.auto</a>.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>tasks</code></td> + + + <td class="type"> + + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>An object, each of whose properties is an <a href="global.html">AsyncFunction</a> of +the form 'func([dependencies...], callback). The object's key of a property +serves as the name of the task defined by that property, i.e. can be used +when specifying requirements for other tasks.</p> +<ul> +<li>The <code>callback</code> parameter is a <code>callback(err, result)</code> which must be called +when finished, passing an <code>error</code> (which can be <code>null</code>) and the result of +the function's execution. The remaining parameters name other tasks on +which the task is dependent, and the results from those tasks are the +arguments of those parameters.</li> +</ul></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>An optional callback which is called when all +the tasks have been completed. It receives the <code>err</code> argument if any <code>tasks</code> +pass an error to their callback, and a <code>results</code> object with any completed +task results, similar to <code>auto</code>.</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback is passed</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>// The example from `auto` can be rewritten as follows: +async.autoInject({ + get_data: function(callback) { + // async code to get some data + callback(null, 'data', 'converted to array'); + }, + make_folder: function(callback) { + // async code to create a directory to store a file in + // this is run at the same time as getting the data + callback(null, 'folder'); + }, + write_file: function(get_data, make_folder, callback) { + // once there is some data and the directory exists, + // write the data to a file in the directory + callback(null, 'filename'); + }, + email_link: function(write_file, callback) { + // once the file is written let's email a link to it... + // write_file contains the filename returned by write_file. + callback(null, {'file':write_file, 'email':'user@example.com'}); + } +}, function(err, results) { + console.log('err = ', err); + console.log('email_link = ', results.email_link); +}); + +// If you are using a JS minifier that mangles parameter names, `autoInject` +// will not work with plain functions, since the parameter names will be +// collapsed to a single letter identifier. To work around this, you can +// explicitly specify the names of the parameters your task function needs +// in an array, similar to Angular.js dependency injection. + +// This still has an advantage over plain `auto`, since the results a task +// depends on are still spread into arguments. +async.autoInject({ + //... + write_file: ['get_data', 'make_folder', function(get_data, make_folder, callback) { + callback(null, 'filename'); + }], + email_link: ['write_file', function(write_file, callback) { + callback(null, {'file':write_file, 'email':'user@example.com'}); + }] + //... +}, function(err, results) { + console.log('err = ', err); + console.log('email_link = ', results.email_link); +});</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="autoInject.js.html">autoInject.js</a>, <a href="autoInject.js.html#line25">line 25</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#auto">async.auto</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="cargo"><span class="type-signature">(static) </span>cargo<span class="signature">(worker, payload<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {<a href="#QueueObject">QueueObject</a>}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import cargo from 'async/cargo';</code></pre><p>Creates a <code>cargo</code> object with the specified payload. Tasks added to the +cargo will be processed altogether (up to the <code>payload</code> limit). If the +<code>worker</code> is in progress, the task is queued until it becomes available. Once +the <code>worker</code> has completed some tasks, each callback of those tasks is +called. Check out <a href="https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966">these</a> <a href="https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966">animations</a> +for how <code>cargo</code> and <code>queue</code> work.</p> +<p>While <a href="#queue"><code>queue</code></a> passes only one task to one of a group of workers +at a time, cargo passes an array of tasks to a single worker, repeating +when the worker is finished.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + <th>Default</th> + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>worker</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + <td class="default"> + + </td> + + + <td class="description last"><p>An asynchronous function for processing an array +of queued tasks. Invoked with <code>(tasks, callback)</code>.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>payload</code></td> + + + <td class="type"> + + +<span class="param-type">number</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + <td class="default"> + + Infinity + + </td> + + + <td class="description last"><p>An optional <code>integer</code> for determining +how many tasks should be processed per round; if omitted, the default is +unlimited.</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>A cargo object to manage the tasks. Callbacks can +attached as certain properties to listen for specific events during the +lifecycle of the cargo and inner queue.</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type"><a href="#QueueObject">QueueObject</a></span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>// create a cargo object with payload 2 +var cargo = async.cargo(function(tasks, callback) { + for (var i=0; i<tasks.length; i++) { + console.log('hello ' + tasks[i].name); + } + callback(); +}, 2); + +// add some items +cargo.push({name: 'foo'}, function(err) { + console.log('finished processing foo'); +}); +cargo.push({name: 'bar'}, function(err) { + console.log('finished processing bar'); +}); +await cargo.push({name: 'baz'}); +console.log('finished processing baz');</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="cargo.js.html">cargo.js</a>, <a href="cargo.js.html#line3">line 3</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#queue">async.queue</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="cargoQueue"><span class="type-signature">(static) </span>cargoQueue<span class="signature">(worker, concurrency<span class="signature-attributes">opt</span>, payload<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {module:ControlFlow.CargoObject}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import cargoQueue from 'async/cargoQueue';</code></pre><p>Creates a <code>cargoQueue</code> object with the specified payload. Tasks added to the +cargoQueue will be processed together (up to the <code>payload</code> limit) in <code>concurrency</code> parallel workers. +If the all <code>workers</code> are in progress, the task is queued until one becomes available. Once +a <code>worker</code> has completed some tasks, each callback of those tasks is +called. Check out <a href="https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966">these</a> <a href="https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966">animations</a> +for how <code>cargo</code> and <code>queue</code> work.</p> +<p>While <a href="#queue"><code>queue</code></a> passes only one task to one of a group of workers +at a time, and <a href="#cargo"><code>cargo</code></a> passes an array of tasks to a single worker, +the cargoQueue passes an array of tasks to multiple parallel workers.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + <th>Default</th> + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>worker</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + <td class="default"> + + </td> + + + <td class="description last"><p>An asynchronous function for processing an array +of queued tasks. Invoked with <code>(tasks, callback)</code>.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>concurrency</code></td> + + + <td class="type"> + + +<span class="param-type">number</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + <td class="default"> + + 1 + + </td> + + + <td class="description last"><p>An <code>integer</code> for determining how many +<code>worker</code> functions should be run in parallel. If omitted, the concurrency +defaults to <code>1</code>. If the concurrency is <code>0</code>, an error is thrown.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>payload</code></td> + + + <td class="type"> + + +<span class="param-type">number</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + <td class="default"> + + Infinity + + </td> + + + <td class="description last"><p>An optional <code>integer</code> for determining +how many tasks should be processed per round; if omitted, the default is +unlimited.</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>A cargoQueue object to manage the tasks. Callbacks can +attached as certain properties to listen for specific events during the +lifecycle of the cargoQueue and inner queue.</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">CargoObject</span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>// create a cargoQueue object with payload 2 and concurrency 2 +var cargoQueue = async.cargoQueue(function(tasks, callback) { + for (var i=0; i<tasks.length; i++) { + console.log('hello ' + tasks[i].name); + } + callback(); +}, 2, 2); + +// add some items +cargoQueue.push({name: 'foo'}, function(err) { + console.log('finished processing foo'); +}); +cargoQueue.push({name: 'bar'}, function(err) { + console.log('finished processing bar'); +}); +cargoQueue.push({name: 'baz'}, function(err) { + console.log('finished processing baz'); +}); +cargoQueue.push({name: 'boo'}, function(err) { + console.log('finished processing boo'); +});</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="cargoQueue.js.html">cargoQueue.js</a>, <a href="cargoQueue.js.html#line3">line 3</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#queue">async.queue</a></p></li> + + <li><p>async.cargo</p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="compose"><span class="type-signature">(static) </span>compose<span class="signature">(…functions)</span><span class="type-signature"> → {function}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import compose from 'async/compose';</code></pre><p>Creates a function which is a composition of the passed asynchronous +functions. Each function consumes the return value of the function that +follows. Composing functions <code>f()</code>, <code>g()</code>, and <code>h()</code> would produce the result +of <code>f(g(h()))</code>, only this version uses callbacks to obtain the return values.</p> +<p>If the last argument to the composed function is not a function, a promise +is returned when you call it.</p> +<p>Each function is executed with the <code>this</code> binding of the composed function.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>functions</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>the asynchronous functions to compose</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>an asynchronous function that is the composed +asynchronous <code>functions</code></p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">function</span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>function add1(n, callback) { + setTimeout(function () { + callback(null, n + 1); + }, 10); +} + +function mul3(n, callback) { + setTimeout(function () { + callback(null, n * 3); + }, 10); +} + +var add1mul3 = async.compose(mul3, add1); +add1mul3(4, function (err, result) { + // result now equals 15 +});</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="compose.js.html">compose.js</a>, <a href="compose.js.html#line3">line 3</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="doUntil"><span class="type-signature">(static) </span>doUntil<span class="signature">(iteratee, test, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import doUntil from 'async/doUntil';</code></pre><p>Like <a href="#doWhilst">'doWhilst'</a>, except the <code>test</code> is inverted. Note the +argument ordering differs from <code>until</code>.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>An async function which is called each time +<code>test</code> fails. Invoked with (callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>test</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>asynchronous truth test to perform after each +execution of <code>iteratee</code>. Invoked with (...args, callback), where <code>...args</code> are the +non-error args from the previous callback of <code>iteratee</code></p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called after the test +function has passed and repeated execution of <code>iteratee</code> has stopped. <code>callback</code> +will be passed an error and any arguments passed to the final <code>iteratee</code>'s +callback. Invoked with (err, [results]);</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback is passed</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="doUntil.js.html">doUntil.js</a>, <a href="doUntil.js.html#line4">line 4</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#doWhilst">async.doWhilst</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="doWhilst"><span class="type-signature">(static) </span>doWhilst<span class="signature">(iteratee, test, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import doWhilst from 'async/doWhilst';</code></pre><p>The post-check version of <a href="#whilst"><code>whilst</code></a>. To reflect the difference in +the order of operations, the arguments <code>test</code> and <code>iteratee</code> are switched.</p> +<p><code>doWhilst</code> is to <code>whilst</code> as <code>do while</code> is to <code>while</code> in plain JavaScript.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>A function which is called each time <code>test</code> +passes. Invoked with (callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>test</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>asynchronous truth test to perform after each +execution of <code>iteratee</code>. Invoked with (...args, callback), where <code>...args</code> are the +non-error args from the previous callback of <code>iteratee</code>.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called after the test +function has failed and repeated execution of <code>iteratee</code> has stopped. +<code>callback</code> will be passed an error and any arguments passed to the final +<code>iteratee</code>'s callback. Invoked with (err, [results]);</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback is passed</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="doWhilst.js.html">doWhilst.js</a>, <a href="doWhilst.js.html#line5">line 5</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#whilst">async.whilst</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="forever"><span class="type-signature">(static) </span>forever<span class="signature">(fn, errback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import forever from 'async/forever';</code></pre><p>Calls the asynchronous function <code>fn</code> with a callback parameter that allows it +to call itself again, in series, indefinitely. +If an error is passed to the callback then <code>errback</code> is called with the +error, and execution stops, otherwise it will never be called.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>fn</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>an async function to call repeatedly. +Invoked with (next).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>errback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>when <code>fn</code> passes an error to it's callback, +this function will be called, and execution stops. Invoked with (err).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise that rejects if an error occurs and an errback +is not passed</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>async.forever( + function(next) { + // next is suitable for passing to things that need a callback(err [, whatever]); + // it will result in this function being called again. + }, + function(err) { + // if next is called with a value in its first parameter, it will appear + // in here as 'err', and execution will stop. + } +);</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="forever.js.html">forever.js</a>, <a href="forever.js.html#line6">line 6</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="parallel"><span class="type-signature">(static) </span>parallel<span class="signature">(tasks, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import parallel from 'async/parallel';</code></pre><p>Run the <code>tasks</code> collection of functions in parallel, without waiting until +the previous function has completed. If any of the functions pass an error to +its callback, the main <code>callback</code> is immediately called with the value of the +error. Once the <code>tasks</code> have completed, the results are passed to the final +<code>callback</code> as an array.</p> +<p><strong>Note:</strong> <code>parallel</code> is about kicking-off I/O tasks in parallel, not about +parallel execution of code. If your tasks do not use any timers or perform +any I/O, they will actually be executed in series. Any synchronous setup +sections for each task will happen one after the other. JavaScript remains +single-threaded.</p> +<p><strong>Hint:</strong> Use <a href="#reflect"><code>reflect</code></a> to continue the +execution of other tasks when a task fails.</p> +<p>It is also possible to use an object instead of an array. Each property will +be run as a function and the results will be passed to the final <code>callback</code> +as an object instead of an array. This can be a more readable way of handling +results from async.parallel.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>tasks</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection of +<a href="global.html">async functions</a> to run. +Each async function can complete with any number of optional <code>result</code> values.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>An optional callback to run once all the +functions have completed successfully. This function gets a results array +(or object) containing all the result arguments passed to the task callbacks. +Invoked with (err, results).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if a callback is not passed</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>async.parallel([ + function(callback) { + setTimeout(function() { + callback(null, 'one'); + }, 200); + }, + function(callback) { + setTimeout(function() { + callback(null, 'two'); + }, 100); + } +], +// optional callback +function(err, results) { + // the results array will equal ['one','two'] even though + // the second function had a shorter timeout. +}); + +// an example using an object instead of an array +async.parallel({ + one: function(callback) { + setTimeout(function() { + callback(null, 1); + }, 200); + }, + two: function(callback) { + setTimeout(function() { + callback(null, 2); + }, 100); + } +}, function(err, results) { + // results is now equals to: {one: 1, two: 2} +});</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="parallel.js.html">parallel.js</a>, <a href="parallel.js.html#line4">line 4</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="parallelLimit"><span class="type-signature">(static) </span>parallelLimit<span class="signature">(tasks, limit, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import parallelLimit from 'async/parallelLimit';</code></pre><p>The same as <a href="#parallel"><code>parallel</code></a> but runs a maximum of <code>limit</code> async operations at a +time.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>tasks</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection of +<a href="global.html">async functions</a> to run. +Each async function can complete with any number of optional <code>result</code> values.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>limit</code></td> + + + <td class="type"> + + +<span class="param-type">number</span> + + + + + + </td> + + + + <td class="description last"><p>The maximum number of async operations at a time.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>An optional callback to run once all the +functions have completed successfully. This function gets a results array +(or object) containing all the result arguments passed to the task callbacks. +Invoked with (err, results).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if a callback is not passed</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="parallelLimit.js.html">parallelLimit.js</a>, <a href="parallelLimit.js.html#line4">line 4</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#parallel">async.parallel</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="priorityQueue"><span class="type-signature">(static) </span>priorityQueue<span class="signature">(worker, concurrency)</span><span class="type-signature"> → {<a href="#QueueObject">QueueObject</a>}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import priorityQueue from 'async/priorityQueue';</code></pre><p>The same as <a href="#queue">async.queue</a> only tasks are assigned a priority and +completed in ascending priority order.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>worker</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>An async function for processing a queued task. +If you want to handle errors from an individual task, pass a callback to +<code>q.push()</code>. +Invoked with (task, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>concurrency</code></td> + + + <td class="type"> + + +<span class="param-type">number</span> + + + + + + </td> + + + + <td class="description last"><p>An <code>integer</code> for determining how many <code>worker</code> +functions should be run in parallel. If omitted, the concurrency defaults to +<code>1</code>. If the concurrency is <code>0</code>, an error is thrown.</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>A priorityQueue object to manage the tasks. There are two +differences between <code>queue</code> and <code>priorityQueue</code> objects:</p> +<ul> +<li><code>push(task, priority, [callback])</code> - <code>priority</code> should be a number. If an +array of <code>tasks</code> is given, all tasks will be assigned the same priority.</li> +<li>The <code>unshift</code> method was removed.</li> +</ul> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type"><a href="#QueueObject">QueueObject</a></span> + + + </dd> +</dl> + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="priorityQueue.js.html">priorityQueue.js</a>, <a href="priorityQueue.js.html#line5">line 5</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#queue">async.queue</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="queue"><span class="type-signature">(static) </span>queue<span class="signature">(worker, concurrency<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {<a href="#QueueObject">QueueObject</a>}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import queue from 'async/queue';</code></pre><p>Creates a <code>queue</code> object with the specified <code>concurrency</code>. Tasks added to the +<code>queue</code> are processed in parallel (up to the <code>concurrency</code> limit). If all +<code>worker</code>s are in progress, the task is queued until one becomes available. +Once a <code>worker</code> completes a <code>task</code>, that <code>task</code>'s callback is called.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + <th>Default</th> + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>worker</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + <td class="default"> + + </td> + + + <td class="description last"><p>An async function for processing a queued task. +If you want to handle errors from an individual task, pass a callback to +<code>q.push()</code>. Invoked with (task, callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>concurrency</code></td> + + + <td class="type"> + + +<span class="param-type">number</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + <td class="default"> + + 1 + + </td> + + + <td class="description last"><p>An <code>integer</code> for determining how many +<code>worker</code> functions should be run in parallel. If omitted, the concurrency +defaults to <code>1</code>. If the concurrency is <code>0</code>, an error is thrown.</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>A queue object to manage the tasks. Callbacks can be +attached as certain properties to listen for specific events during the +lifecycle of the queue.</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type"><a href="#QueueObject">QueueObject</a></span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>// create a queue object with concurrency 2 +var q = async.queue(function(task, callback) { + console.log('hello ' + task.name); + callback(); +}, 2); + +// assign a callback +q.drain(function() { + console.log('all items have been processed'); +}); +// or await the end +await q.drain() + +// assign an error callback +q.error(function(err, task) { + console.error('task experienced an error'); +}); + +// add some items to the queue +q.push({name: 'foo'}, function(err) { + console.log('finished processing foo'); +}); +// callback is optional +q.push({name: 'bar'}); + +// add some items to the queue (batch-wise) +q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function(err) { + console.log('finished processing item'); +}); + +// add some items to the front of the queue +q.unshift({name: 'bar'}, function (err) { + console.log('finished processing bar'); +});</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="queue.js.html">queue.js</a>, <a href="queue.js.html#line85">line 85</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="race"><span class="type-signature">(static) </span>race<span class="signature">(tasks, callback)</span><span class="type-signature"></span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import race from 'async/race';</code></pre><p>Runs the <code>tasks</code> array of functions in parallel, without waiting until the +previous function has completed. Once any of the <code>tasks</code> complete or pass an +error to its callback, the main <code>callback</code> is immediately called. It's +equivalent to <code>Promise.race()</code>.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>tasks</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> + + + + + + </td> + + + + <td class="description last"><p>An array containing <a href="global.html">async functions</a> +to run. Each function can complete with an optional <code>result</code> value.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + </td> + + + + <td class="description last"><p>A callback to run once any of the functions have +completed. This function gets an error or result from the first function that +completed. Invoked with (err, result).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>undefined</p> +</div> + + + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>async.race([ + function(callback) { + setTimeout(function() { + callback(null, 'one'); + }, 200); + }, + function(callback) { + setTimeout(function() { + callback(null, 'two'); + }, 100); + } +], +// main callback +function(err, result) { + // the result will be equal to 'two' as it finishes earlier +});</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="race.js.html">race.js</a>, <a href="race.js.html#line5">line 5</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="retry"><span class="type-signature">(static) </span>retry<span class="signature">(opts<span class="signature-attributes">opt</span>, task, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import retry from 'async/retry';</code></pre><p>Attempts to get a successful response from <code>task</code> no more than <code>times</code> times +before returning an error. If the task is successful, the <code>callback</code> will be +passed the result of the successful task. If all attempts fail, the callback +will be passed the error and result (if any) of the final attempt.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + <th>Default</th> + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>opts</code></td> + + + <td class="type"> + + +<span class="param-type">Object</span> +| + +<span class="param-type">number</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + <td class="default"> + + {times: 5, interval: 0}| 5 + + </td> + + + <td class="description last"><p>Can be either an +object with <code>times</code> and <code>interval</code> or a number.</p> +<ul> +<li><code>times</code> - The number of attempts to make before giving up. The default +is <code>5</code>.</li> +<li><code>interval</code> - The time to wait between retries, in milliseconds. The +default is <code>0</code>. The interval may also be specified as a function of the +retry count (see example).</li> +<li><code>errorFilter</code> - An optional synchronous function that is invoked on +erroneous result. If it returns <code>true</code> the retry attempts will continue; +if the function returns <code>false</code> the retry flow is aborted with the current +attempt's error and result being returned to the final callback. +Invoked with (err).</li> +<li>If <code>opts</code> is a number, the number specifies the number of times to retry, +with the default interval of <code>0</code>.</li> +</ul></td> + </tr> + + + + <tr> + + <td class="name"><code>task</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + <td class="default"> + + </td> + + + <td class="description last"><p>An async function to retry. +Invoked with (callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + <td class="default"> + + </td> + + + <td class="description last"><p>An optional callback which is called when the +task has succeeded, or after the final failed attempt. It receives the <code>err</code> +and <code>result</code> arguments of the last attempt at completing the <code>task</code>. Invoked +with (err, results).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise if no callback provided</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>// The `retry` function can be used as a stand-alone control flow by passing +// a callback, as shown below: + +// try calling apiMethod 3 times +async.retry(3, apiMethod, function(err, result) { + // do something with the result +}); + +// try calling apiMethod 3 times, waiting 200 ms between each retry +async.retry({times: 3, interval: 200}, apiMethod, function(err, result) { + // do something with the result +}); + +// try calling apiMethod 10 times with exponential backoff +// (i.e. intervals of 100, 200, 400, 800, 1600, ... milliseconds) +async.retry({ + times: 10, + interval: function(retryCount) { + return 50 * Math.pow(2, retryCount); + } +}, apiMethod, function(err, result) { + // do something with the result +}); + +// try calling apiMethod the default 5 times no delay between each retry +async.retry(apiMethod, function(err, result) { + // do something with the result +}); + +// try calling apiMethod only when error condition satisfies, all other +// errors will abort the retry control flow and return to final callback +async.retry({ + errorFilter: function(err) { + return err.message === 'Temporary error'; // only retry on a specific error + } +}, apiMethod, function(err, result) { + // do something with the result +}); + +// to retry individual methods that are not as reliable within other +// control flow functions, use the `retryable` wrapper: +async.auto({ + users: api.getUsers.bind(api), + payments: async.retryable(3, api.getPayments.bind(api)) +}, function(err, results) { + // do something with the results +});</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="retry.js.html">retry.js</a>, <a href="retry.js.html#line10">line 10</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#retryable">async.retryable</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="retryable"><span class="type-signature">(static) </span>retryable<span class="signature">(opts<span class="signature-attributes">opt</span>, task)</span><span class="type-signature"> → {<a href="global.html">AsyncFunction</a>}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import retryable from 'async/retryable';</code></pre><p>A close relative of <a href="#retry"><code>retry</code></a>. This method +wraps a task and makes it retryable, rather than immediately calling it +with retries.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + <th>Default</th> + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>opts</code></td> + + + <td class="type"> + + +<span class="param-type">Object</span> +| + +<span class="param-type">number</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + <td class="default"> + + {times: 5, interval: 0}| 5 + + </td> + + + <td class="description last"><p>optional +options, exactly the same as from <code>retry</code>, except for a <code>opts.arity</code> that +is the arity of the <code>task</code> function, defaulting to <code>task.length</code></p></td> + </tr> + + + + <tr> + + <td class="name"><code>task</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + <td class="default"> + + </td> + + + <td class="description last"><p>the asynchronous function to wrap. +This function will be passed any arguments passed to the returned wrapper. +Invoked with (...args, callback).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>The wrapped function, which when invoked, will +retry on an error, based on the parameters specified in <code>opts</code>. +This function will accept the same parameters as <code>task</code>.</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>async.auto({ + dep1: async.retryable(3, getFromFlakyService), + process: ["dep1", async.retryable(3, function (results, cb) { + maybeProcessData(results.dep1, cb); + })] +}, callback);</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="retryable.js.html">retryable.js</a>, <a href="retryable.js.html#line6">line 6</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#retry">async.retry</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="seq"><span class="type-signature">(static) </span>seq<span class="signature">(…functions)</span><span class="type-signature"> → {function}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import seq from 'async/seq';</code></pre><p>Version of the compose function that is more natural to read. Each function +consumes the return value of the previous function. It is the equivalent of +<a href="#compose">compose</a> with the arguments reversed.</p> +<p>Each function is executed with the <code>this</code> binding of the composed function.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>functions</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>the asynchronous functions to compose</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a function that composes the <code>functions</code> in order</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">function</span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>// Requires lodash (or underscore), express3 and dresende's orm2. +// Part of an app, that fetches cats of the logged user. +// This example uses `seq` function to avoid overnesting and error +// handling clutter. +app.get('/cats', function(request, response) { + var User = request.models.User; + async.seq( + _.bind(User.get, User), // 'User.get' has signature (id, callback(err, data)) + function(user, fn) { + user.getCats(fn); // 'getCats' has signature (callback(err, data)) + } + )(req.session.user_id, function (err, cats) { + if (err) { + console.error(err); + response.json({ status: 'error', message: err.message }); + } else { + response.json({ status: 'ok', message: 'Cats found', data: cats }); + } + }); +});</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="seq.js.html">seq.js</a>, <a href="seq.js.html#line5">line 5</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#compose">async.compose</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="series"><span class="type-signature">(static) </span>series<span class="signature">(tasks, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import series from 'async/series';</code></pre><p>Run the functions in the <code>tasks</code> collection in series, each one running once +the previous function has completed. If any functions in the series pass an +error to its callback, no more functions are run, and <code>callback</code> is +immediately called with the value of the error. Otherwise, <code>callback</code> +receives an array of results when <code>tasks</code> have completed.</p> +<p>It is also possible to use an object instead of an array. Each property will +be run as a function, and the results will be passed to the final <code>callback</code> +as an object instead of an array. This can be a more readable way of handling + results from async.series.</p> +<p><strong>Note</strong> that while many implementations preserve the order of object +properties, the <a href="http://www.ecma-international.org/ecma-262/5.1/#sec-8.6">ECMAScript Language Specification</a> +explicitly states that</p> +<blockquote> +<p>The mechanics and order of enumerating the properties is not specified.</p> +</blockquote> +<p>So if you rely on the order in which your series of functions are executed, +and want this to work on all platforms, consider using an array.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>tasks</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection containing +<a href="global.html">async functions</a> to run in series. +Each function can complete with any number of optional <code>result</code> values.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>An optional callback to run once all the +functions have completed. This function gets a results array (or object) +containing all the result arguments passed to the <code>task</code> callbacks. Invoked +with (err, result).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback is passed</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>async.series([ + function(callback) { + // do some stuff ... + callback(null, 'one'); + }, + function(callback) { + // do some more stuff ... + callback(null, 'two'); + } +], +// optional callback +function(err, results) { + // results is now equal to ['one', 'two'] +}); + +async.series({ + one: function(callback) { + setTimeout(function() { + callback(null, 1); + }, 200); + }, + two: function(callback){ + setTimeout(function() { + callback(null, 2); + }, 100); + } +}, function(err, results) { + // results is now equal to: {one: 1, two: 2} +});</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="series.js.html">series.js</a>, <a href="series.js.html#line4">line 4</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="times"><span class="type-signature">(static) </span>times<span class="signature">(n, iteratee, callback)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import times from 'async/times';</code></pre><p>Calls the <code>iteratee</code> function <code>n</code> times, and accumulates results in the same +manner you would use with <a href="#map">map</a>.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>n</code></td> + + + <td class="type"> + + +<span class="param-type">number</span> + + + + + + </td> + + + + <td class="description last"><p>The number of times to run the function.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>The async function to call <code>n</code> times. +Invoked with the iteration index and a callback: (n, next).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + </td> + + + + <td class="description last"><p>see <a href="#map">map</a>.</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback is provided</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>// Pretend this is some complicated async factory +var createUser = function(id, callback) { + callback(null, { + id: 'user' + id + }); +}; + +// generate 5 users +async.times(5, function(n, next) { + createUser(n, function(err, user) { + next(err, user); + }); +}, function(err, users) { + // we should now have 5 users +});</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="times.js.html">times.js</a>, <a href="times.js.html#line3">line 3</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#map">async.map</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="timesLimit"><span class="type-signature">(static) </span>timesLimit<span class="signature">(count, limit, iteratee, callback)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import timesLimit from 'async/timesLimit';</code></pre><p>The same as <a href="#times">times</a> but runs a maximum of <code>limit</code> async operations at a +time.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>count</code></td> + + + <td class="type"> + + +<span class="param-type">number</span> + + + + + + </td> + + + + <td class="description last"><p>The number of times to run the function.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>limit</code></td> + + + <td class="type"> + + +<span class="param-type">number</span> + + + + + + </td> + + + + <td class="description last"><p>The maximum number of async operations at a time.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>The async function to call <code>n</code> times. +Invoked with the iteration index and a callback: (n, next).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + </td> + + + + <td class="description last"><p>see <a href="#map">async.map</a>.</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback is provided</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="timesLimit.js.html">timesLimit.js</a>, <a href="timesLimit.js.html#line5">line 5</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#times">async.times</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="timesSeries"><span class="type-signature">(static) </span>timesSeries<span class="signature">(n, iteratee, callback)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import timesSeries from 'async/timesSeries';</code></pre><p>The same as <a href="#times">times</a> but runs only a single async operation at a time.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>n</code></td> + + + <td class="type"> + + +<span class="param-type">number</span> + + + + + + </td> + + + + <td class="description last"><p>The number of times to run the function.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>The async function to call <code>n</code> times. +Invoked with the iteration index and a callback: (n, next).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + </td> + + + + <td class="description last"><p>see <a href="#map">map</a>.</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback is provided</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="timesSeries.js.html">timesSeries.js</a>, <a href="timesSeries.js.html#line3">line 3</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#times">async.times</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="tryEach"><span class="type-signature">(static) </span>tryEach<span class="signature">(tasks, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import tryEach from 'async/tryEach';</code></pre><p>It runs each task in series but stops whenever any of the functions were +successful. If one of the tasks were successful, the <code>callback</code> will be +passed the result of the successful task. If all tasks fail, the callback +will be passed the error and result (if any) of the final attempt.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>tasks</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Iterable</span> +| + +<span class="param-type">AsyncIterable</span> +| + +<span class="param-type">Object</span> + + + + + + </td> + + + + <td class="description last"><p>A collection containing functions to +run, each function is passed a <code>callback(err, result)</code> it must call on +completion with an error <code>err</code> (which can be <code>null</code>) and an optional <code>result</code> +value.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>An optional callback which is called when one +of the tasks has succeeded, or all have failed. It receives the <code>err</code> and +<code>result</code> arguments of the last attempt at completing the <code>task</code>. Invoked with +(err, results).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback is passed</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>async.tryEach([ + function getDataFromFirstWebsite(callback) { + // Try getting the data from the first website + callback(err, data); + }, + function getDataFromSecondWebsite(callback) { + // First website failed, + // Try getting the data from the backup website + callback(err, data); + } +], +// optional callback +function(err, results) { + Now do something with the data. +});</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="tryEach.js.html">tryEach.js</a>, <a href="tryEach.js.html#line5">line 5</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="until"><span class="type-signature">(static) </span>until<span class="signature">(test, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import until from 'async/until';</code></pre><p>Repeatedly call <code>iteratee</code> until <code>test</code> returns <code>true</code>. Calls <code>callback</code> when +stopped, or an error occurs. <code>callback</code> will be passed an error and any +arguments passed to the final <code>iteratee</code>'s callback.</p> +<p>The inverse of <a href="#whilst">whilst</a>.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>test</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>asynchronous truth test to perform before each +execution of <code>iteratee</code>. Invoked with (callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>An async function which is called each time +<code>test</code> fails. Invoked with (callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called after the test +function has passed and repeated execution of <code>iteratee</code> has stopped. <code>callback</code> +will be passed an error and any arguments passed to the final <code>iteratee</code>'s +callback. Invoked with (err, [results]);</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if a callback is not passed</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>const results = [] +async.until(function iter(next) { + fetchPage(url, (err, body) => { + if (err) return next(err) + results = results.concat(body.objects) + next(err, body) + }) +}, function test(page, cb) { + cb(null, page.next == null) +}, function done (err) { + // all pages have been fetched +})</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="until.js.html">until.js</a>, <a href="until.js.html#line4">line 4</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#whilst">async.whilst</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="waterfall"><span class="type-signature">(static) </span>waterfall<span class="signature">(tasks, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import waterfall from 'async/waterfall';</code></pre><p>Runs the <code>tasks</code> array of functions in series, each passing their results to +the next in the array. However, if any of the <code>tasks</code> pass an error to their +own callback, the next function is not executed, and the main <code>callback</code> is +immediately called with the error.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>tasks</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> + + + + + + </td> + + + + <td class="description last"><p>An array of <a href="global.html">async functions</a> +to run. +Each function should complete with any number of <code>result</code> values. +The <code>result</code> values will be passed as arguments, in order, to the next task.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>An optional callback to run once all the +functions have completed. This will be passed the results of the last task's +callback. Invoked with (err, [results]).</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>undefined</p> +</div> + + + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>async.waterfall([ + function(callback) { + callback(null, 'one', 'two'); + }, + function(arg1, arg2, callback) { + // arg1 now equals 'one' and arg2 now equals 'two' + callback(null, 'three'); + }, + function(arg1, callback) { + // arg1 now equals 'three' + callback(null, 'done'); + } +], function (err, result) { + // result now equals 'done' +}); + +// Or, with named functions: +async.waterfall([ + myFirstFunction, + mySecondFunction, + myLastFunction, +], function (err, result) { + // result now equals 'done' +}); +function myFirstFunction(callback) { + callback(null, 'one', 'two'); +} +function mySecondFunction(arg1, arg2, callback) { + // arg1 now equals 'one' and arg2 now equals 'two' + callback(null, 'three'); +} +function myLastFunction(arg1, callback) { + // arg1 now equals 'three' + callback(null, 'done'); +}</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="waterfall.js.html">waterfall.js</a>, <a href="waterfall.js.html#line7">line 7</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="whilst"><span class="type-signature">(static) </span>whilst<span class="signature">(test, iteratee, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import whilst from 'async/whilst';</code></pre><p>Repeatedly call <code>iteratee</code>, while <code>test</code> returns <code>true</code>. Calls <code>callback</code> when +stopped, or an error occurs.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>test</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>asynchronous truth test to perform before each +execution of <code>iteratee</code>. Invoked with ().</p></td> + </tr> + + + + <tr> + + <td class="name"><code>iteratee</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>An async function which is called each time +<code>test</code> passes. Invoked with (callback).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>A callback which is called after the test +function has failed and repeated execution of <code>iteratee</code> has stopped. <code>callback</code> +will be passed an error and any arguments passed to the final <code>iteratee</code>'s +callback. Invoked with (err, [results]);</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a promise, if no callback is passed</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Promise</span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>var count = 0; +async.whilst( + function test(cb) { cb(null, count < 5;) }, + function iter(callback) { + count++; + setTimeout(function() { + callback(null, count); + }, 1000); + }, + function (err, n) { + // 5 seconds have passed, n = 5 + } +);</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="whilst.js.html">whilst.js</a>, <a href="whilst.js.html#line5">line 5</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + <h3 class="subsection-title">Type Definitions</h3> + + + +<h4 class="name" id="QueueObject">QueueObject</h4> + + + + +<div class="description"> + <pre class="prettyprint source"><code>import queue from 'async/queue';</code></pre><p>A queue of tasks for the worker function to complete.</p> +</div> + + + + <h5>Type:</h5> + <ul> + <li> + +<span class="param-type">Iterable</span> + + + </li> + </ul> + + + + + + <h5 class="subsection-title">Properties:</h5> + + + +<table class="props"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>length</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + </td> + + + + + + <td class="description last"><p>a function returning the number of items +waiting to be processed. Invoke with <code>queue.length()</code>.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>started</code></td> + + + <td class="type"> + + +<span class="param-type">boolean</span> + + + + </td> + + + + + + <td class="description last"><p>a boolean indicating whether or not any +items have been pushed and processed by the queue.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>running</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + </td> + + + + + + <td class="description last"><p>a function returning the number of items +currently being processed. Invoke with <code>queue.running()</code>.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>workersList</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + </td> + + + + + + <td class="description last"><p>a function returning the array of items +currently being processed. Invoke with <code>queue.workersList()</code>.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>idle</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + </td> + + + + + + <td class="description last"><p>a function returning false if there are items +waiting or being processed, or true if not. Invoke with <code>queue.idle()</code>.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>concurrency</code></td> + + + <td class="type"> + + +<span class="param-type">number</span> + + + + </td> + + + + + + <td class="description last"><p>an integer for determining how many <code>worker</code> +functions should be run in parallel. This property can be changed after a +<code>queue</code> is created to alter the concurrency on-the-fly.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>payload</code></td> + + + <td class="type"> + + +<span class="param-type">number</span> + + + + </td> + + + + + + <td class="description last"><p>an integer that specifies how many items are +passed to the worker function at a time. only applies if this is a +<a href="#cargo">cargo</a> object</p></td> + </tr> + + + + <tr> + + <td class="name"><code>push</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + </td> + + + + + + <td class="description last"><p>add a new task to the <code>queue</code>. Calls <code>callback</code> +once the <code>worker</code> has finished processing the task. Instead of a single task, +a <code>tasks</code> array can be submitted. The respective callback is used for every +task in the list. Invoke with <code>queue.push(task, [callback])</code>,</p></td> + </tr> + + + + <tr> + + <td class="name"><code>unshift</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + </td> + + + + + + <td class="description last"><p>add a new task to the front of the <code>queue</code>. +Invoke with <code>queue.unshift(task, [callback])</code>.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>remove</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + </td> + + + + + + <td class="description last"><p>remove items from the queue that match a test +function. The test function will be passed an object with a <code>data</code> property, +and a <code>priority</code> property, if this is a +<a href="#priorityQueue">priorityQueue</a> object. +Invoked with <code>queue.remove(testFn)</code>, where <code>testFn</code> is of the form +<code>function ({data, priority}) {}</code> and returns a Boolean.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>saturated</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + </td> + + + + + + <td class="description last"><p>a function that sets a callback that is +called when the number of running workers hits the <code>concurrency</code> limit, and +further tasks will be queued. If the callback is omitted, <code>q.saturated()</code> +returns a promise for the next occurrence.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>unsaturated</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + </td> + + + + + + <td class="description last"><p>a function that sets a callback that is +called when the number of running workers is less than the <code>concurrency</code> & +<code>buffer</code> limits, and further tasks will not be queued. If the callback is +omitted, <code>q.unsaturated()</code> returns a promise for the next occurrence.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>buffer</code></td> + + + <td class="type"> + + +<span class="param-type">number</span> + + + + </td> + + + + + + <td class="description last"><p>A minimum threshold buffer in order to say that +the <code>queue</code> is <code>unsaturated</code>.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>empty</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + </td> + + + + + + <td class="description last"><p>a function that sets a callback that is called +when the last item from the <code>queue</code> is given to a <code>worker</code>. If the callback +is omitted, <code>q.empty()</code> returns a promise for the next occurrence.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>drain</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + </td> + + + + + + <td class="description last"><p>a function that sets a callback that is called +when the last item from the <code>queue</code> has returned from the <code>worker</code>. If the +callback is omitted, <code>q.drain()</code> returns a promise for the next occurrence.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>error</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + </td> + + + + + + <td class="description last"><p>a function that sets a callback that is called +when a task errors. Has the signature <code>function(error, task)</code>. If the +callback is omitted, <code>error()</code> returns a promise that rejects on the next +error.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>paused</code></td> + + + <td class="type"> + + +<span class="param-type">boolean</span> + + + + </td> + + + + + + <td class="description last"><p>a boolean for determining whether the queue is +in a paused state.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>pause</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + </td> + + + + + + <td class="description last"><p>a function that pauses the processing of tasks +until <code>resume()</code> is called. Invoke with <code>queue.pause()</code>.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>resume</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + </td> + + + + + + <td class="description last"><p>a function that resumes the processing of +queued tasks when the queue is paused. Invoke with <code>queue.resume()</code>.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>kill</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + </td> + + + + + + <td class="description last"><p>a function that removes the <code>drain</code> callback and +empties remaining tasks from the queue forcing it to go idle. No more tasks +should be pushed to the queue after calling this function. Invoke with <code>queue.kill()</code>.</p></td> + </tr> + + + </tbody> +</table> + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="queue.js.html">queue.js</a>, <a href="queue.js.html#line4">line 4</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>const q = aync.queue(worker, 2) +q.push(item1) +q.push(item2) +q.push(item3) +// queues are iterable, spread into an array to inspect +const items = [...q] // [item1, item2, item3] +// or use for of +for (let item of q) { + console.log(item) +} + +q.drain(() => { + console.log('all done') +}) +// or +await q.drain()</code></pre> + + + + + + + +</article> + +</section> + + + + + + + <h1 class="page-title" id="utils">Utils</h1> + + + + + + + +<section> + +<header> + + + + + +</header> + +<article> + <div class="container-overview"> + + + <div class="description"><p>A collection of <code>async</code> utility functions.</p></div> + + + + + + + + + + + + + + + + + + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="index.js.html">index.js</a>, <a href="index.js.html#line61">line 61</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + </div> + + + + + + + + + + + + + + + <h3 class="subsection-title">Methods</h3> + + + + + + + <h4 class="name" id="apply"><span class="type-signature">(static) </span>apply<span class="signature">(fn)</span><span class="type-signature"> → {function}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import apply from 'async/apply';</code></pre><p>Creates a continuation function with some arguments already applied.</p> +<p>Useful as a shorthand when combined with other control flow functions. Any +arguments passed to the returned function are added to the arguments +originally passed to apply.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>fn</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + </td> + + + + <td class="description last"><p>The function you want to eventually apply all +arguments to. Invokes with (arguments...).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>arguments...</code></td> + + + <td class="type"> + + +<span class="param-type">*</span> + + + + + + </td> + + + + <td class="description last"><p>Any number of arguments to automatically apply +when the continuation is called.</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>the partially-applied function</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">function</span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>// using apply +async.parallel([ + async.apply(fs.writeFile, 'testfile1', 'test1'), + async.apply(fs.writeFile, 'testfile2', 'test2') +]); + + +// the same process without using apply +async.parallel([ + function(callback) { + fs.writeFile('testfile1', 'test1', callback); + }, + function(callback) { + fs.writeFile('testfile2', 'test2', callback); + } +]); + +// It's possible to pass any number of additional arguments when calling the +// continuation: + +node> var fn = async.apply(sys.puts, 'one'); +node> fn('two', 'three'); +one +two +three</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="apply.js.html">apply.js</a>, <a href="apply.js.html#line1">line 1</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="asyncify"><span class="type-signature">(static) </span>asyncify<span class="signature">(func)</span><span class="type-signature"> → {<a href="global.html">AsyncFunction</a>}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import asyncify from 'async/asyncify';</code></pre><p>Take a sync function and make it async, passing its return value to a +callback. This is useful for plugging sync functions into a waterfall, +series, or other async functions. Any arguments passed to the generated +function will be passed to the wrapped function (except for the final +callback argument). Errors thrown will be passed to the callback.</p> +<p>If the function passed to <code>asyncify</code> returns a Promise, that promises's +resolved/rejected state will be used to call the callback, rather than simply +the synchronous return value.</p> +<p>This also means you can asyncify ES2017 <code>async</code> functions.</p> +</div> + + + + <dl class="details alias-details"> + <dt class="tag-alias">Alias:</dt> + <dd class="tag-alias"><ul class="dummy"><li>wrapSync</li></ul></dd> + </dl> + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>func</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + </td> + + + + <td class="description last"><p>The synchronous function, or Promise-returning +function to convert to an <a href="global.html">AsyncFunction</a>.</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>An asynchronous wrapper of the <code>func</code>. To be +invoked with <code>(args..., callback)</code>.</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>// passing a regular synchronous function +async.waterfall([ + async.apply(fs.readFile, filename, "utf8"), + async.asyncify(JSON.parse), + function (data, next) { + // data is the result of parsing the text. + // If there was a parsing error, it would have been caught. + } +], callback); + +// passing a function returning a promise +async.waterfall([ + async.apply(fs.readFile, filename, "utf8"), + async.asyncify(function (contents) { + return db.model.create(contents); + }), + function (model, next) { + // `model` is the instantiated model object. + // If there was an error, this function would be skipped. + } +], callback); + +// es2017 example, though `asyncify` is not needed if your JS environment +// supports async functions out of the box +var q = async.queue(async.asyncify(async function(file) { + var intermediateStep = await processFile(file); + return await somePromise(intermediateStep) +})); + +q.push(files);</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="asyncify.js.html">asyncify.js</a>, <a href="asyncify.js.html#line5">line 5</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="constant"><span class="type-signature">(static) </span>constant<span class="signature">()</span><span class="type-signature"> → {<a href="global.html">AsyncFunction</a>}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import constant from 'async/constant';</code></pre><p>Returns a function that when called, calls-back with the values provided. +Useful as the first function in a <a href="#waterfall"><code>waterfall</code></a>, or for plugging values in to +<a href="#auto"><code>auto</code></a>.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>arguments...</code></td> + + + <td class="type"> + + +<span class="param-type">*</span> + + + + + + </td> + + + + <td class="description last"><p>Any number of arguments to automatically invoke +callback with.</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>Returns a function that when invoked, automatically +invokes the callback with the previous given arguments.</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>async.waterfall([ + async.constant(42), + function (value, next) { + // value === 42 + }, + //... +], callback); + +async.waterfall([ + async.constant(filename, "utf8"), + fs.readFile, + function (fileData, next) { + //... + } + //... +], callback); + +async.auto({ + hostname: async.constant("https://server.net/"), + port: findFreePort, + launchServer: ["hostname", "port", function (options, cb) { + startServer(options, cb); + }], + //... +}, callback);</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="constant.js.html">constant.js</a>, <a href="constant.js.html#line1">line 1</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="dir"><span class="type-signature">(static) </span>dir<span class="signature">(function)</span><span class="type-signature"></span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import dir from 'async/dir';</code></pre><p>Logs the result of an <a href="global.html"><code>async</code> function</a> to the +<code>console</code> using <code>console.dir</code> to display the properties of the resulting object. +Only works in Node.js or in browsers that support <code>console.dir</code> and +<code>console.error</code> (such as FF and Chrome). +If multiple arguments are returned from the async function, +<code>console.dir</code> is called on each argument in order.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>function</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>The function you want to eventually apply +all arguments to.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>arguments...</code></td> + + + <td class="type"> + + +<span class="param-type">*</span> + + + + + + </td> + + + + <td class="description last"><p>Any number of arguments to apply to the function.</p></td> + </tr> + + + </tbody> +</table> + + + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>// in a module +var hello = function(name, callback) { + setTimeout(function() { + callback(null, {hello: name}); + }, 1000); +}; + +// in the node repl +node> async.dir(hello, 'world'); +{hello: 'world'}</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="dir.js.html">dir.js</a>, <a href="dir.js.html#line3">line 3</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="ensureAsync"><span class="type-signature">(static) </span>ensureAsync<span class="signature">(fn)</span><span class="type-signature"> → {<a href="global.html">AsyncFunction</a>}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import ensureAsync from 'async/ensureAsync';</code></pre><p>Wrap an async function and ensure it calls its callback on a later tick of +the event loop. If the function already calls its callback on a next tick, +no extra deferral is added. This is useful for preventing stack overflows +(<code>RangeError: Maximum call stack size exceeded</code>) and generally keeping +<a href="http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony">Zalgo</a> +contained. ES2017 <code>async</code> functions are returned as-is -- they are immune +to Zalgo's corrupting influences, as they always resolve on a later tick.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>fn</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>an async function, one that expects a node-style +callback as its last argument.</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>Returns a wrapped function with the exact same call +signature as the function passed in.</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>function sometimesAsync(arg, callback) { + if (cache[arg]) { + return callback(null, cache[arg]); // this would be synchronous!! + } else { + doSomeIO(arg, callback); // this IO would be asynchronous + } +} + +// this has a risk of stack overflows if many results are cached in a row +async.mapSeries(args, sometimesAsync, done); + +// this will defer sometimesAsync's callback if necessary, +// preventing stack overflows +async.mapSeries(args, async.ensureAsync(sometimesAsync), done);</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="ensureAsync.js.html">ensureAsync.js</a>, <a href="ensureAsync.js.html#line4">line 4</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="log"><span class="type-signature">(static) </span>log<span class="signature">(function)</span><span class="type-signature"></span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import log from 'async/log';</code></pre><p>Logs the result of an <code>async</code> function to the <code>console</code>. Only works in +Node.js or in browsers that support <code>console.log</code> and <code>console.error</code> (such +as FF and Chrome). If multiple arguments are returned from the async +function, <code>console.log</code> is called on each argument in order.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>function</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>The function you want to eventually apply +all arguments to.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>arguments...</code></td> + + + <td class="type"> + + +<span class="param-type">*</span> + + + + + + </td> + + + + <td class="description last"><p>Any number of arguments to apply to the function.</p></td> + </tr> + + + </tbody> +</table> + + + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>// in a module +var hello = function(name, callback) { + setTimeout(function() { + callback(null, 'hello ' + name); + }, 1000); +}; + +// in the node repl +node> async.log(hello, 'world'); +'hello world'</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="log.js.html">log.js</a>, <a href="log.js.html#line3">line 3</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="memoize"><span class="type-signature">(static) </span>memoize<span class="signature">(fn, hasher)</span><span class="type-signature"> → {<a href="global.html">AsyncFunction</a>}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import memoize from 'async/memoize';</code></pre><p>Caches the results of an async function. When creating a hash to store +function results against, the callback is omitted from the hash and an +optional hash function can be used.</p> +<p><strong>Note: if the async function errs, the result will not be cached and +subsequent calls will call the wrapped function.</strong></p> +<p>If no hash function is specified, the first argument is used as a hash key, +which may work reasonably if it is a string or a data type that converts to a +distinct string. Note that objects and arrays will not behave reasonably. +Neither will cases where the other arguments are significant. In such cases, +specify your own hash function.</p> +<p>The cache of results is exposed as the <code>memo</code> property of the function +returned by <code>memoize</code>.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>fn</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>The async function to proxy and cache results from.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>hasher</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + </td> + + + + <td class="description last"><p>An optional function for generating a custom hash +for storing results. It has all the arguments applied to it apart from the +callback, and must be synchronous.</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a memoized version of <code>fn</code></p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>var slow_fn = function(name, callback) { + // do something + callback(null, result); +}; +var fn = async.memoize(slow_fn); + +// fn can now be used as if it were slow_fn +fn('some name', function() { + // callback +});</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="memoize.js.html">memoize.js</a>, <a href="memoize.js.html#line5">line 5</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="nextTick"><span class="type-signature">(static) </span>nextTick<span class="signature">(callback)</span><span class="type-signature"></span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import nextTick from 'async/nextTick';</code></pre><p>Calls <code>callback</code> on a later loop around the event loop. In Node.js this just +calls <code>process.nextTick</code>. In the browser it will use <code>setImmediate</code> if +available, otherwise <code>setTimeout(callback, 0)</code>, which means other higher +priority events may precede the execution of <code>callback</code>.</p> +<p>This is used internally for browser-compatibility purposes.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + </td> + + + + <td class="description last"><p>The function to call on a later loop around +the event loop. Invoked with (args...).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>args...</code></td> + + + <td class="type"> + + +<span class="param-type">*</span> + + + + + + </td> + + + + <td class="description last"><p>any number of additional arguments to pass to the +callback on the next tick.</p></td> + </tr> + + + </tbody> +</table> + + + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>var call_order = []; +async.nextTick(function() { + call_order.push('two'); + // call_order now equals ['one','two'] +}); +call_order.push('one'); + +async.setImmediate(function (a, b, c) { + // a, b, and c equal 1, 2, and 3 +}, 1, 2, 3);</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="nextTick.js.html">nextTick.js</a>, <a href="nextTick.js.html#line5">line 5</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#setImmediate">async.setImmediate</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="reflect"><span class="type-signature">(static) </span>reflect<span class="signature">(fn)</span><span class="type-signature"> → {function}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import reflect from 'async/reflect';</code></pre><p>Wraps the async function in another function that always completes with a +result object, even when it errors.</p> +<p>The result object has either the property <code>error</code> or <code>value</code>.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>fn</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>The async function you want to wrap</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <ul> +<li>A function that always passes null to it's callback as +the error. The second argument to the callback will be an <code>object</code> with +either an <code>error</code> or a <code>value</code> property.</li> +</ul> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">function</span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>async.parallel([ + async.reflect(function(callback) { + // do some stuff ... + callback(null, 'one'); + }), + async.reflect(function(callback) { + // do some more stuff but error ... + callback('bad stuff happened'); + }), + async.reflect(function(callback) { + // do some more stuff ... + callback(null, 'two'); + }) +], +// optional callback +function(err, results) { + // values + // results[0].value = 'one' + // results[1].error = 'bad stuff happened' + // results[2].value = 'two' +});</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="reflect.js.html">reflect.js</a>, <a href="reflect.js.html#line4">line 4</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="reflectAll"><span class="type-signature">(static) </span>reflectAll<span class="signature">(tasks)</span><span class="type-signature"> → {Array}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import reflectAll from 'async/reflectAll';</code></pre><p>A helper function that wraps an array or an object of functions with <code>reflect</code>.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>tasks</code></td> + + + <td class="type"> + + +<span class="param-type">Array</span> +| + +<span class="param-type">Object</span> +| + +<span class="param-type">Iterable</span> + + + + + + </td> + + + + <td class="description last"><p>The collection of +<a href="global.html">async functions</a> to wrap in <code>async.reflect</code>.</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>Returns an array of async functions, each wrapped in +<code>async.reflect</code></p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type">Array</span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>let tasks = [ + function(callback) { + setTimeout(function() { + callback(null, 'one'); + }, 200); + }, + function(callback) { + // do some more stuff but error ... + callback(new Error('bad stuff happened')); + }, + function(callback) { + setTimeout(function() { + callback(null, 'two'); + }, 100); + } +]; + +async.parallel(async.reflectAll(tasks), +// optional callback +function(err, results) { + // values + // results[0].value = 'one' + // results[1].error = Error('bad stuff happened') + // results[2].value = 'two' +}); + +// an example using an object instead of an array +let tasks = { + one: function(callback) { + setTimeout(function() { + callback(null, 'one'); + }, 200); + }, + two: function(callback) { + callback('two'); + }, + three: function(callback) { + setTimeout(function() { + callback(null, 'three'); + }, 100); + } +}; + +async.parallel(async.reflectAll(tasks), +// optional callback +function(err, results) { + // values + // results.one.value = 'one' + // results.two.error = 'two' + // results.three.value = 'three' +});</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="reflectAll.js.html">reflectAll.js</a>, <a href="reflectAll.js.html#line3">line 3</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#reflect">async.reflect</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="setImmediate"><span class="type-signature">(static) </span>setImmediate<span class="signature">(callback)</span><span class="type-signature"></span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import setImmediate from 'async/setImmediate';</code></pre><p>Calls <code>callback</code> on a later loop around the event loop. In Node.js this just +calls <code>setImmediate</code>. In the browser it will use <code>setImmediate</code> if +available, otherwise <code>setTimeout(callback, 0)</code>, which means other higher +priority events may precede the execution of <code>callback</code>.</p> +<p>This is used internally for browser-compatibility purposes.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>callback</code></td> + + + <td class="type"> + + +<span class="param-type">function</span> + + + + + + </td> + + + + <td class="description last"><p>The function to call on a later loop around +the event loop. Invoked with (args...).</p></td> + </tr> + + + + <tr> + + <td class="name"><code>args...</code></td> + + + <td class="type"> + + +<span class="param-type">*</span> + + + + + + </td> + + + + <td class="description last"><p>any number of additional arguments to pass to the +callback on the next tick.</p></td> + </tr> + + + </tbody> +</table> + + + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>var call_order = []; +async.nextTick(function() { + call_order.push('two'); + // call_order now equals ['one','two'] +}); +call_order.push('one'); + +async.setImmediate(function (a, b, c) { + // a, b, and c equal 1, 2, and 3 +}, 1, 2, 3);</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="setImmediate.js.html">setImmediate.js</a>, <a href="setImmediate.js.html#line3">line 3</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#nextTick">async.nextTick</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="timeout"><span class="type-signature">(static) </span>timeout<span class="signature">(asyncFn, milliseconds, info<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {<a href="global.html">AsyncFunction</a>}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import timeout from 'async/timeout';</code></pre><p>Sets a time limit on an asynchronous function. If the function does not call +its callback within the specified milliseconds, it will be called with a +timeout error. The code property for the error object will be <code>'ETIMEDOUT'</code>.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>asyncFn</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>The async function to limit in time.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>milliseconds</code></td> + + + <td class="type"> + + +<span class="param-type">number</span> + + + + + + </td> + + + + <td class="description last"><p>The specified time limit.</p></td> + </tr> + + + + <tr> + + <td class="name"><code>info</code></td> + + + <td class="type"> + + +<span class="param-type">*</span> + + + + + + <span class="optional"><optional></span> + + </td> + + + + <td class="description last"><p>Any variable you want attached (<code>string</code>, <code>object</code>, etc) +to timeout Error for more information..</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>Returns a wrapped function that can be used with any +of the control flow functions. +Invoke this function with the same parameters as you would <code>asyncFunc</code>.</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + </dd> +</dl> + + + + + <h5>Example</h5> + + <pre class="prettyprint"><code>function myFunction(foo, callback) { + doAsyncTask(foo, function(err, data) { + // handle errors + if (err) return callback(err); + + // do some stuff ... + + // return processed data + return callback(null, data); + }); +} + +var wrapped = async.timeout(myFunction, 1000); + +// call `wrapped` as you would `myFunction` +wrapped({ bar: 'bar' }, function(err, data) { + // if `myFunction` takes < 1000 ms to execute, `err` + // and `data` will have their expected values + + // else `err` will be an Error with the code 'ETIMEDOUT' +});</code></pre> + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="timeout.js.html">timeout.js</a>, <a href="timeout.js.html#line4">line 4</a> + </li></ul></dd> + + + + + + + +</dl> + + + + + + + + + + + + + + + + + + <h4 class="name" id="unmemoize"><span class="type-signature">(static) </span>unmemoize<span class="signature">(fn)</span><span class="type-signature"> → {<a href="global.html">AsyncFunction</a>}</span></h4> + + + + + +<div class="description"> + <pre class="prettyprint source"><code>import unmemoize from 'async/unmemoize';</code></pre><p>Undoes a <a href="#memoize">memoize</a>d function, reverting it to the original, +unmemoized form. Handy for testing.</p> +</div> + + + + + + + + + + + + <h5>Parameters:</h5> + + +<table class="params"> + <thead> + <tr> + + <th>Name</th> + + + <th>Type</th> + + + + + <th class="last">Description</th> + </tr> + </thead> + + <tbody> + + + <tr> + + <td class="name"><code>fn</code></td> + + + <td class="type"> + + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + + + + </td> + + + + <td class="description last"><p>the memoized function</p></td> + </tr> + + + </tbody> +</table> + + + + +<h5>Returns:</h5> + + +<div class="param-desc"> + <p>a function that calls the original unmemoized function</p> +</div> + + + +<dl class="param-type"> + <dt> + Type + </dt> + <dd> + +<span class="param-type"><a href="global.html">AsyncFunction</a></span> + + + </dd> +</dl> + + + + + + + + +<dl class="details"> + + + + + + + + + + + + + + + + + + + + + + + + + + + <dt class="tag-source">Source:</dt> + <dd class="tag-source"><ul class="dummy"><li> + <a href="unmemoize.js.html">unmemoize.js</a>, <a href="unmemoize.js.html#line1">line 1</a> + </li></ul></dd> + + + + + + <dt class="tag-see">See:</dt> + <dd class="tag-see"> + <ul> + <li><p><a href="#memoize">async.memoize</a></p></li> + </ul> + </dd> + + + +</dl> + + + + + + + + + + + + + + + + + + +</article> + +</section> + + + + + <footer> + Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> using the Minami theme. +</footer></div> +</div> + +<nav id="toc"> + <h3>Methods:</h3><ul class="nav methods"><li class="toc-header"><a href="#collections">Collections</a></li><li data-type="method" class="toc-method"><a href="#concat">concat</a></li><li data-type="method" class="toc-method"><a href="#concatLimit">concatLimit</a></li><li data-type="method" class="toc-method"><a href="#concatSeries">concatSeries</a></li><li data-type="method" class="toc-method"><a href="#detect">detect</a></li><li data-type="method" class="toc-method"><a href="#detectLimit">detectLimit</a></li><li data-type="method" class="toc-method"><a href="#detectSeries">detectSeries</a></li><li data-type="method" class="toc-method"><a href="#each">each</a></li><li data-type="method" class="toc-method"><a href="#eachLimit">eachLimit</a></li><li data-type="method" class="toc-method"><a href="#eachOf">eachOf</a></li><li data-type="method" class="toc-method"><a href="#eachOfLimit">eachOfLimit</a></li><li data-type="method" class="toc-method"><a href="#eachOfSeries">eachOfSeries</a></li><li data-type="method" class="toc-method"><a href="#eachSeries">eachSeries</a></li><li data-type="method" class="toc-method"><a href="#every">every</a></li><li data-type="method" class="toc-method"><a href="#everyLimit">everyLimit</a></li><li data-type="method" class="toc-method"><a href="#everySeries">everySeries</a></li><li data-type="method" class="toc-method"><a href="#filter">filter</a></li><li data-type="method" class="toc-method"><a href="#filterLimit">filterLimit</a></li><li data-type="method" class="toc-method"><a href="#filterSeries">filterSeries</a></li><li data-type="method" class="toc-method"><a href="#groupBy">groupBy</a></li><li data-type="method" class="toc-method"><a href="#groupByLimit">groupByLimit</a></li><li data-type="method" class="toc-method"><a href="#groupBySeries">groupBySeries</a></li><li data-type="method" class="toc-method"><a href="#map">map</a></li><li data-type="method" class="toc-method"><a href="#mapLimit">mapLimit</a></li><li data-type="method" class="toc-method"><a href="#mapSeries">mapSeries</a></li><li data-type="method" class="toc-method"><a href="#mapValues">mapValues</a></li><li data-type="method" class="toc-method"><a href="#mapValuesLimit">mapValuesLimit</a></li><li data-type="method" class="toc-method"><a href="#mapValuesSeries">mapValuesSeries</a></li><li data-type="method" class="toc-method"><a href="#reduce">reduce</a></li><li data-type="method" class="toc-method"><a href="#reduceRight">reduceRight</a></li><li data-type="method" class="toc-method"><a href="#reject">reject</a></li><li data-type="method" class="toc-method"><a href="#rejectLimit">rejectLimit</a></li><li data-type="method" class="toc-method"><a href="#rejectSeries">rejectSeries</a></li><li data-type="method" class="toc-method"><a href="#some">some</a></li><li data-type="method" class="toc-method"><a href="#someLimit">someLimit</a></li><li data-type="method" class="toc-method"><a href="#someSeries">someSeries</a></li><li data-type="method" class="toc-method"><a href="#sortBy">sortBy</a></li><li data-type="method" class="toc-method"><a href="#transform">transform</a></li><li class="toc-header"><a href="#controlflow">Control Flow</a></li><li data-type="method" class="toc-method"><a href="#applyEach">applyEach</a></li><li data-type="method" class="toc-method"><a href="#applyEachSeries">applyEachSeries</a></li><li data-type="method" class="toc-method"><a href="#auto">auto</a></li><li data-type="method" class="toc-method"><a href="#autoInject">autoInject</a></li><li data-type="method" class="toc-method"><a href="#cargo">cargo</a></li><li data-type="method" class="toc-method"><a href="#cargoQueue">cargoQueue</a></li><li data-type="method" class="toc-method"><a href="#compose">compose</a></li><li data-type="method" class="toc-method"><a href="#doUntil">doUntil</a></li><li data-type="method" class="toc-method"><a href="#doWhilst">doWhilst</a></li><li data-type="method" class="toc-method"><a href="#forever">forever</a></li><li data-type="method" class="toc-method"><a href="#parallel">parallel</a></li><li data-type="method" class="toc-method"><a href="#parallelLimit">parallelLimit</a></li><li data-type="method" class="toc-method"><a href="#priorityQueue">priorityQueue</a></li><li data-type="method" class="toc-method"><a href="#queue">queue</a></li><li data-type="method" class="toc-method"><a href="#race">race</a></li><li data-type="method" class="toc-method"><a href="#retry">retry</a></li><li data-type="method" class="toc-method"><a href="#retryable">retryable</a></li><li data-type="method" class="toc-method"><a href="#seq">seq</a></li><li data-type="method" class="toc-method"><a href="#series">series</a></li><li data-type="method" class="toc-method"><a href="#times">times</a></li><li data-type="method" class="toc-method"><a href="#timesLimit">timesLimit</a></li><li data-type="method" class="toc-method"><a href="#timesSeries">timesSeries</a></li><li data-type="method" class="toc-method"><a href="#tryEach">tryEach</a></li><li data-type="method" class="toc-method"><a href="#until">until</a></li><li data-type="method" class="toc-method"><a href="#waterfall">waterfall</a></li><li data-type="method" class="toc-method"><a href="#whilst">whilst</a></li><li class="toc-header"><a href="#utils">Utils</a></li><li data-type="method" class="toc-method"><a href="#apply">apply</a></li><li data-type="method" class="toc-method"><a href="#asyncify">asyncify</a></li><li data-type="method" class="toc-method"><a href="#constant">constant</a></li><li data-type="method" class="toc-method"><a href="#dir">dir</a></li><li data-type="method" class="toc-method"><a href="#ensureAsync">ensureAsync</a></li><li data-type="method" class="toc-method"><a href="#log">log</a></li><li data-type="method" class="toc-method"><a href="#memoize">memoize</a></li><li data-type="method" class="toc-method"><a href="#nextTick">nextTick</a></li><li data-type="method" class="toc-method"><a href="#reflect">reflect</a></li><li data-type="method" class="toc-method"><a href="#reflectAll">reflectAll</a></li><li data-type="method" class="toc-method"><a href="#setImmediate">setImmediate</a></li><li data-type="method" class="toc-method"><a href="#timeout">timeout</a></li><li data-type="method" class="toc-method"><a href="#unmemoize">unmemoize</a></li></ul><h3>Methods:</h3> +</nav> + +<br class="clear"> + + + + +<script src="https://cdn.jsdelivr.net/prettify/0.1/prettify.js"></script> + +<script src="https://cdn.jsdelivr.net/jquery/2.2.4/jquery.min.js"></script> +<script src="https://cdn.jsdelivr.net/bootstrap/3.3.6/js/bootstrap.min.js"></script> +<script src="https://cdn.jsdelivr.net/typeahead.js/0.11.1/typeahead.bundle.min.js"></script> +<script>prettyPrint();</script> +<script src="scripts/async.js"></script> + +<script src="scripts/linenumber.js" async></script> +<script src="scripts/jsdoc-custom.js" async></script> +</body>
\ No newline at end of file |