summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Early <alexander.early@gmail.com>2016-06-30 16:02:09 -0700
committerGitHub <noreply@github.com>2016-06-30 16:02:09 -0700
commit13fcbf491d6428415c3e0bb525993fb1f366bee6 (patch)
tree47e5f372d69602b2b18960ec77b711e9ca31bb88
parentb7081631c373bf459f1108824f870c62328ed8d6 (diff)
parent209fb1eb12342cc6efe80a600d8a2566f806e28a (diff)
downloadasync-13fcbf491d6428415c3e0bb525993fb1f366bee6.tar.gz
Merge pull request #1202 from hargasinski/docs-pr
static doc site generation
-rw-r--r--README.md2006
-rw-r--r--lib/apply.js3
-rw-r--r--lib/applyEach.js3
-rw-r--r--lib/applyEachSeries.js7
-rw-r--r--lib/asyncify.js3
-rw-r--r--lib/auto.js3
-rw-r--r--lib/autoInject.js9
-rw-r--r--lib/cargo.js28
-rw-r--r--lib/compose.js3
-rw-r--r--lib/concat.js3
-rw-r--r--lib/concatSeries.js7
-rw-r--r--lib/constant.js7
-rw-r--r--lib/detect.js7
-rw-r--r--lib/detectLimit.js9
-rw-r--r--lib/detectSeries.js9
-rw-r--r--lib/dir.js5
-rw-r--r--lib/doDuring.js9
-rw-r--r--lib/doUntil.js7
-rw-r--r--lib/doWhilst.js7
-rw-r--r--lib/during.js7
-rw-r--r--lib/each.js3
-rw-r--r--lib/eachLimit.js7
-rw-r--r--lib/eachOf.js6
-rw-r--r--lib/eachOfLimit.js7
-rw-r--r--lib/eachOfSeries.js7
-rw-r--r--lib/eachSeries.js7
-rw-r--r--lib/ensureAsync.js3
-rw-r--r--lib/every.js3
-rw-r--r--lib/everyLimit.js7
-rw-r--r--lib/everySeries.js7
-rw-r--r--lib/filter.js3
-rw-r--r--lib/filterLimit.js7
-rw-r--r--lib/filterSeries.js7
-rw-r--r--lib/forever.js3
-rw-r--r--lib/index.js16
-rw-r--r--lib/iterator.js3
-rw-r--r--lib/log.js3
-rw-r--r--lib/map.js3
-rw-r--r--lib/mapLimit.js7
-rw-r--r--lib/mapSeries.js7
-rw-r--r--lib/mapValues.js5
-rw-r--r--lib/mapValuesLimit.js7
-rw-r--r--lib/mapValuesSeries.js7
-rw-r--r--lib/memoize.js3
-rw-r--r--lib/nextTick.js3
-rw-r--r--lib/parallel.js3
-rw-r--r--lib/parallelLimit.js9
-rw-r--r--lib/priorityQueue.js9
-rw-r--r--lib/queue.js28
-rw-r--r--lib/race.js3
-rw-r--r--lib/reduce.js3
-rw-r--r--lib/reduceRight.js7
-rw-r--r--lib/reflect.js3
-rw-r--r--lib/reflectAll.js5
-rw-r--r--lib/reject.js7
-rw-r--r--lib/rejectLimit.js7
-rw-r--r--lib/rejectSeries.js7
-rw-r--r--lib/retry.js3
-rw-r--r--lib/retryable.js7
-rw-r--r--lib/seq.js7
-rw-r--r--lib/series.js3
-rw-r--r--lib/setImmediate.js3
-rw-r--r--lib/some.js3
-rw-r--r--lib/someLimit.js7
-rw-r--r--lib/someSeries.js7
-rw-r--r--lib/sortBy.js3
-rw-r--r--lib/timeout.js3
-rw-r--r--lib/times.js9
-rw-r--r--lib/timesLimit.js11
-rw-r--r--lib/timesSeries.js9
-rw-r--r--lib/transform.js3
-rw-r--r--lib/unmemoize.js7
-rw-r--r--lib/until.js7
-rw-r--r--lib/waterfall.js3
-rw-r--r--lib/whilst.js3
-rw-r--r--package.json9
-rw-r--r--support/esdoc.json6
-rw-r--r--support/jsdoc/head-data.html10
-rw-r--r--support/jsdoc/jsdoc-custom.css83
-rw-r--r--support/jsdoc/jsdoc-custom.js105
-rw-r--r--support/jsdoc/jsdoc-fix-html.js212
-rw-r--r--support/jsdoc/jsdoc-import-path-plugin.js21
-rw-r--r--support/jsdoc/jsdoc.json20
-rw-r--r--support/jsdoc/navbar.html30
84 files changed, 785 insertions, 2183 deletions
diff --git a/README.md b/README.md
index adaee57..4000fdd 100644
--- a/README.md
+++ b/README.md
@@ -57,7 +57,8 @@ There are many more functions available so take a look at the docs below for a
full list. This module aims to be comprehensive, so if you feel anything is
missing please create a GitHub issue for it.
-## Common Pitfalls <sub>[(StackOverflow)](http://stackoverflow.com/questions/tagged/async.js)</sub>
+## Common Pitfalls [(StackOverflow)](http://stackoverflow.com/questions/tagged/async.js)
+
### Synchronous iteration functions
If you get an error like `RangeError: Maximum call stack size exceeded.` or other stack overflow issues when using async, you are likely using a synchronous iteratee. By *synchronous* we mean a function that calls its callback on the same tick in the javascript event loop, without doing any I/O or using any timers. Calling many callbacks iteratively will quickly overflow the stack. If you run into this issue, just defer your callback with `async.setImmediate` to start a new call stack on the next tick of the event loop.
@@ -160,11 +161,15 @@ The source is available for download from
[GitHub](https://raw.githubusercontent.com/caolan/async/master/dist/async.min.js).
Alternatively, you can install using npm:
- npm install --save async
+```bash
+$ npm install --save async
+```
As well as using Bower:
- bower install async
+```bash
+$ bower install async
+```
You can then `require()` async as normal:
@@ -202,2001 +207,12 @@ Usage:
We also provide async as a collection of ES2015 modules, in an alternative `async-es` package on npm.
- npm i -S async-es
+```bash
+$ npm install --save async-es
+```
```js
import waterfall from 'async-es/waterfall';
import async from 'async-es';
```
-## Documentation
-
-Some functions are also available in the following forms:
-* `<name>Series` - the same as `<name>` but runs only a single async operation at a time
-* `<name>Limit` - the same as `<name>` but runs a maximum of `limit` async operations at a time
-
-### Collections
-
-* [`each`](#each), `eachSeries`, `eachLimit`
-* [`forEachOf`](#forEachOf), `forEachOfSeries`, `forEachOfLimit`
-* [`map`](#map), `mapSeries`, `mapLimit`
-* [`filter`](#filter), `filterSeries`, `filterLimit`
-* [`reject`](#reject), `rejectSeries`, `rejectLimit`
-* [`reduce`](#reduce), [`reduceRight`](#reduceRight)
-* [`transform`](#transform)
-* [`detect`](#detect), `detectSeries`, `detectLimit`
-* [`sortBy`](#sortBy)
-* [`some`](#some), `someLimit`, `someSeries`
-* [`every`](#every), `everyLimit`, `everySeries`
-* [`concat`](#concat), `concatSeries`
-
-### Control Flow
-
-* [`series`](#seriestasks-callback)
-* [`parallel`](#parallel), `parallelLimit`
-* [`whilst`](#whilst), [`doWhilst`](#doWhilst)
-* [`until`](#until), [`doUntil`](#doUntil)
-* [`during`](#during), [`doDuring`](#doDuring)
-* [`forever`](#forever)
-* [`waterfall`](#waterfall)
-* [`compose`](#compose)
-* [`seq`](#seq)
-* [`applyEach`](#applyEach), `applyEachSeries`
-* [`queue`](#queue), [`priorityQueue`](#priorityQueue)
-* [`cargo`](#cargo)
-* [`auto`](#auto)
-* [`autoInject`](#autoInject)
-* [`retry`](#retry)
-* [`retryable`](#retryable)
-* [`iterator`](#iterator)
-* [`times`](#times), `timesSeries`, `timesLimit`
-* [`race`](#race)
-
-### Utils
-
-* [`apply`](#apply)
-* [`nextTick`](#nextTick)
-* [`memoize`](#memoize)
-* [`unmemoize`](#unmemoize)
-* [`ensureAsync`](#ensureAsync)
-* [`constant`](#constant)
-* [`asyncify`](#asyncify)
-* [`wrapSync`](#wrapSync)
-* [`log`](#log)
-* [`dir`](#dir)
-* [`noConflict`](#noConflict)
-* [`timeout`](#timeout)
-* [`reflect`](#reflect)
-* [`reflectAll`](#reflectAll)
-
-## Collections
-
-Collection methods can iterate over Arrays, Objects, Maps, Sets, and any object that implements the ES2015 iterator protocol.
-
-<a name="forEach"></a>
-<a name="each"></a>
-
-### each(coll, iteratee, [callback])
-
-Applies the function `iteratee` to each item in `coll`, in parallel.
-The `iteratee` is called with an item from the list, and a callback for when it
-has finished. If the `iteratee` passes an error to its `callback`, the main
-`callback` (for the `each` function) is immediately called with the error.
-
-Note, that since this function applies `iteratee` to each item in parallel,
-there is no guarantee that the iteratee functions will complete in order.
-
-__Arguments__
-
-* `coll` - A collection to iterate over.
-* `iteratee(item, callback)` - A function to apply to each item in `coll`.
- The iteratee is passed a `callback(err)` which must be called once it has
- completed. If no error has occurred, the `callback` should be run without
- arguments or with an explicit `null` argument. The array index is not passed
- to the iteratee. If you need the index, use [`forEachOf`](#forEachOf).
-* `callback(err)` - *Optional* A callback which is called when all `iteratee` functions
- have finished, or an error occurs.
-
-__Examples__
-
-
-```js
-// 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
-});
-```
-
-```js
-// 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');
- }
-});
-```
-
-__Related__
-
-* eachSeries(coll, iteratee, [callback])
-* eachLimit(coll, limit, iteratee, [callback])
-
----------------------------------------
-
-<a name="forEachOf"></a>
-<a name="eachOf"></a>
-
-### forEachOf(coll, iteratee, [callback])
-
-Like `each`, except that it passes the key (or index) as the second argument to the iteratee.
-
-__Arguments__
-
-* `coll` - A collection to iterate over.
-* `iteratee(item, key, callback)` - A function to apply to each item in `coll`.
-The `key` is the item's key, or index in the case of an array. The iteratee is
-passed a `callback(err)` which must be called once it has completed. If no
-error has occurred, the callback should be run without arguments or with an
-explicit `null` argument.
-* `callback(err)` - *Optional* A callback which is called when all `iteratee` functions have finished, or an error occurs.
-
-__Example__
-
-```js
-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);
-})
-```
-
-__Related__
-
-* forEachOfSeries(coll, iteratee, [callback])
-* forEachOfLimit(coll, limit, iteratee, [callback])
-
----------------------------------------
-
-<a name="map"></a>
-
-### map(coll, iteratee, [callback])
-
-Produces a new collection of values by mapping each value in `coll` through
-the `iteratee` function. The `iteratee` is called with an item from `coll` and a
-callback for when it has finished processing. Each of these callback takes 2 arguments:
-an `error`, and the transformed item from `coll`. If `iteratee` passes an error to its
-callback, the main `callback` (for the `map` function) is immediately called with the error.
-
-Note, that since this function applies the `iteratee` to each item in parallel,
-there is no guarantee that the `iteratee` functions will complete in order.
-However, the results array will be in the same order as the original `coll`.
-
-__Arguments__
-
-* `coll` - A collection to iterate over.
-* `iteratee(item, callback)` - A function to apply to each item in `coll`.
- The iteratee is passed a `callback(err, transformed)` which must be called once
- it has completed with an error (which can be `null`) and a transformed item.
-* `callback(err, results)` - *Optional* A callback which is called when all `iteratee`
- functions have finished, or an error occurs. Results is an array of the
- transformed items from the `coll`.
-
-__Example__
-
-```js
-async.map(['file1','file2','file3'], fs.stat, function(err, results){
- // results is now an array of stats for each file
-});
-```
-
-__Related__
-
-* mapSeries(coll, iteratee, [callback])
-* mapLimit(coll, limit, iteratee, [callback])
-
----------------------------------------
-
-<a name="select"></a>
-<a name="filter"></a>
-
-### filter(coll, iteratee, [callback])
-
-__Alias:__ `select`
-
-Returns a new array of all the values in `coll` 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.
-
-__Arguments__
-
-* `coll` - A collection to iterate over.
-* `iteratee(item, callback)` - A truth test to apply to each item in `coll`.
- The `iteratee` is passed a `callback(err, truthValue)` , which must be called with a boolean argument once it has completed. **Callback arguments changed in 2.0**
-* `callback(err, results)` - *Optional* A callback which is called after all the `iteratee`
- functions have finished.
-
-__Example__
-
-```js
-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
-});
-```
-
-__Related__
-
-* filterSeries(coll, iteratee, [callback])
-* filterLimit(coll, limit, iteratee, [callback])
-
----------------------------------------
-
-<a name="reject"></a>
-
-### reject(coll, iteratee, [callback])
-
-The opposite of [`filter`](#filter). Removes values that pass an `async` truth test.
-
-__Related__
-
-* rejectSeries(coll, iteratee, [callback])
-* rejectLimit(coll, limit, iteratee, [callback])
-
----------------------------------------
-
-<a name="reduce"></a>
-
-### reduce(coll, memo, iteratee, [callback])
-
-__Aliases:__ `inject`, `foldl`
-
-Reduces `coll` into a single value using an async `iteratee` to return
-each successive step. `memo` is the initial state of the reduction.
-This function only operates in series.
-
-For performance reasons, it may make sense to split a call to this function into
-a parallel map, and then use the normal `Array.prototype.reduce` 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.
-
-__Arguments__
-
-* `coll` - A collection to iterate over.
-* `memo` - The initial state of the reduction.
-* `iteratee(memo, item, callback)` - A function applied to each item in the
- array to produce the next step in the reduction. The `iteratee` is passed a
- `callback(err, reduction)` which accepts an optional error as its first
- argument, and the state of the reduction as the second. If an error is
- passed to the callback, the reduction is stopped and the main `callback` is
- immediately called with the error.
-* `callback(err, result)` - *Optional* A callback which is called after all the `iteratee`
- functions have finished. Result is the reduced value.
-
-__Example__
-
-```js
-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
-});
-```
-
----------------------------------------
-
-<a name="reduceRight"></a>
-
-### reduceRight(coll, memo, iteratee, [callback])
-
-__Alias:__ `foldr`
-
-Same as [`reduce`](#reduce), only operates on `coll` in reverse order.
-
----------------------------------------
-
-<a name="detect"></a>
-
-### detect(coll, iteratee, [callback])
-
-__Alias:__ `find`
-
-Returns the first value in `coll` that passes an async truth test. The
-`iteratee` is applied in parallel, meaning the first iteratee to return `true` will
-fire the detect `callback` with that result. That means the result might not be
-the first item in the original `coll` (in terms of order) that passes the test.
-
-If order within the original `coll` is important, then look at `detectSeries`.
-
-__Arguments__
-
-* `coll` - A collection to iterate over.
-* `iteratee(item, callback)` - A truth test to apply to each item in `coll`. The iteratee is passed a `callback(err, truthValue)` which must be called with a boolean argument once it has completed. **Callback arguments changed in 2.0**
-* `callback(err, result)` - *Optional* A callback which is called as soon as any iteratee returns
- `true`, or after all the `iteratee` functions have finished. Result will be
- the first item in the array that passes the truth test (iteratee) or the
- value `undefined` if none passed.
-
-__Example__
-
-```js
-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
-});
-```
-
-__Related__
-
-* detectSeries(coll, iteratee, [callback])
-* detectLimit(coll, limit, iteratee, [callback])
-
----------------------------------------
-
-<a name="sortBy"></a>
-
-### sortBy(coll, iteratee, [callback])
-
-Sorts a list by the results of running each `coll` value through an async `iteratee`.
-
-__Arguments__
-
-* `coll` - A collection to iterate over.
-* `iteratee(item, callback)` - A function to apply to each item in `coll`.
- The iteratee is passed a `callback(err, sortValue)` which must be called once it
- has completed with an error (which can be `null`) and a value to use as the sort
- criteria.
-* `callback(err, results)` - *Optional* A callback which is called after all the `iteratee`
- functions have finished, or an error occurs. Results is the items from
- the original `coll` sorted by the values returned by the `iteratee` calls.
-
-__Example__
-
-```js
-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
-});
-```
-
-__Sort Order__
-
-By modifying the callback parameter the sorting order can be influenced:
-
-```js
-//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
-} );
-```
-
----------------------------------------
-
-<a name="some"></a>
-
-### some(coll, iteratee, [callback])
-
-__Alias:__ `any`
-
-Returns `true` if at least one element in the `coll` satisfies an async test.
-If any iteratee call returns `true`, the main `callback` is immediately called.
-
-__Arguments__
-
-* `coll` - A collection to iterate over.
-* `iteratee(item, callback)` - A truth test to apply to each item in the array
- in parallel. The iteratee is passed a `callback(err, truthValue)` which must be called with a boolean argument once it has completed. **Callback arguments changed in 2.0**
-* `callback(err, result)` - *Optional* A callback which is called as soon as any iteratee returns
- `true`, or after all the iteratee functions have finished. Result will be
- either `true` or `false` depending on the values of the async tests.
-
-__Example__
-
-```js
-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
-});
-```
-
-__Related__
-
-* someSeries(coll, iteratee, callback)
-* someLimit(coll, limit, iteratee, callback)
-
----------------------------------------
-
-<a name="every"></a>
-
-### every(coll, iteratee, [callback])
-
-__Alias:__ `all`
-
-Returns `true` if every element in `coll` satisfies an async test.
-If any iteratee call returns `false`, the main `callback` is immediately called.
-
-__Arguments__
-
-* `coll` - A collection to iterate over.
-* `iteratee(item, callback)` - A truth test to apply to each item in the collection in parallel. The iteratee is passed a `callback(err, truthValue)` which must be called with a boolean argument once it has completed. **Callback arguments changed in 2.0**
-* `callback(err, result)` - *Optional* A callback which is called after all the `iteratee`
- functions have finished. Result will be either `true` or `false` depending on
- the values of the async tests.
-
-__Example__
-
-```js
-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
-});
-```
-
-__Related__
-
-* everySeries(coll, iteratee, callback)
-* everyLimit(coll, limit, iteratee, callback)
-
----------------------------------------
-
-<a name="concat"></a>
-
-### concat(coll, iteratee, [callback])
-
-Applies `iteratee` to each item in `coll`, concatenating the results. Returns the
-concatenated list. The `iteratee`s are called in parallel, and the results are
-concatenated as they return. There is no guarantee that the results array will
-be returned in the original order of `coll` passed to the `iteratee` function.
-
-__Arguments__
-
-* `coll` - A collection to iterate over.
-* `iteratee(item, callback)` - A function to apply to each item in `coll`.
- The iteratee is passed a `callback(err, results)` which must be called once it
- has completed with an error (which can be `null`) and an array of results.
-* `callback(err, results)` - *Optional* A callback which is called after all the `iteratee`
- functions have finished, or an error occurs. Results is an array containing
- the concatenated results of the `iteratee` function.
-
-__Example__
-
-```js
-async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files){
- // files is now a list of filenames that exist in the 3 directories
-});
-```
-
-__Related__
-
-* concatSeries(coll, iteratee, [callback])
-
-
-## Control Flow
-
-<a name="series"></a>
-
-### series(tasks, [callback])
-
-Run the functions in the `tasks` 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 `callback` is immediately called with the value of the error.
-Otherwise, `callback` receives an array of results when `tasks` have completed.
-
-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 `callback` as an object
-instead of an array. This can be a more readable way of handling results from
-[`series`](#series).
-
-**Note** that while many implementations preserve the order of object properties, the
-[ECMAScript Language Specification](http://www.ecma-international.org/ecma-262/5.1/#sec-8.6)
-explicitly states that
-
-> The mechanics and order of enumerating the properties is not specified.
-
-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.
-
-__Arguments__
-
-* `tasks` - A collection containing functions to run, each function is passed
- a `callback(err, result)` it must call on completion with an error `err` (which can
- be `null`) and an optional `result` value.
-* `callback(err, results)` - 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 `task` callbacks.
-
-__Example__
-
-```js
-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']
-});
-
-
-// an example using an object instead of an array
-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}
-});
-```
-
----------------------------------------
-
-<a name="parallel"></a>
-
-### parallel(tasks, [callback])
-
-Run the `tasks` 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 `callback` is immediately called with the value of the error.
-Once the `tasks` have completed, the results are passed to the final `callback` as an
-array.
-
-**Note:** `parallel` 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.
-
-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 `callback` as an object
-instead of an array. This can be a more readable way of handling results from
-[`parallel`](#parallel).
-
-
-__Arguments__
-
-* `tasks` - A collection containing functions to run. Each function is passed
- a `callback(err, result)` which it must call on completion with an error `err`
- (which can be `null`) and an optional `result` value.
-* `callback(err, results)` - 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.
-
-__Example__
-
-```js
-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}
-});
-```
-
-__Related__
-
-* parallelLimit(tasks, limit, [callback])
-
----------------------------------------
-
-<a name="whilst"></a>
-
-### whilst(test, fn, callback)
-
-Repeatedly call `fn`, while `test` returns `true`. Calls `callback` when stopped,
-or an error occurs.
-
-__Arguments__
-
-* `test()` - synchronous truth test to perform before each execution of `fn`.
-* `fn(callback)` - A function which is called each time `test` passes. The function is
- passed a `callback(err)`, which must be called once it has completed with an
- optional `err` argument.
-* `callback(err, [results])` - A callback which is called after the test
- function has failed and repeated execution of `fn` has stopped. `callback`
- will be passed an error and any arguments passed to the final `fn`'s callback.
-
-__Example__
-
-```js
-var count = 0;
-
-async.whilst(
- function () { return count < 5; },
- function (callback) {
- count++;
- setTimeout(function () {
- callback(null, count);
- }, 1000);
- },
- function (err, n) {
- // 5 seconds have passed, n = 5
- }
-);
-```
-
----------------------------------------
-
-<a name="doWhilst"></a>
-
-### doWhilst(fn, test, callback)
-
-The post-check version of [`whilst`](#whilst). To reflect the difference in
-the order of operations, the arguments `test` and `fn` are switched. The `test` function is also passed the non-error callback results of `fn`.
-
-`doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript.
-
----------------------------------------
-
-<a name="until"></a>
-
-### until(test, fn, callback)
-
-Repeatedly call `fn` until `test` returns `true`. Calls `callback` when stopped,
-or an error occurs. `callback` will be passed an error and any arguments passed
-to the final `fn`'s callback.
-
-The inverse of [`whilst`](#whilst).
-
----------------------------------------
-
-<a name="doUntil"></a>
-
-### doUntil(fn, test, callback)
-
-Like [`doWhilst`](#doWhilst), except the `test` is inverted. Note the argument ordering differs from `until`. The `test` function is also passed the non-error callback results of `fn`.
-
----------------------------------------
-
-<a name="during"></a>
-
-### during(test, fn, callback)
-
-Like [`whilst`](#whilst), except the `test` is an asynchronous function that is passed a callback in the form of `function (err, truth)`. If error is passed to `test` or `fn`, the main callback is immediately called with the value of the error.
-
-Additionaly `during` passes any arguments passed by the iteratee function (2nd function) to the test function (1st function). The test callback will allways be the last parameter.
-
-__Example__
-
-```js
-var count = 0;
-
-async.during(
- function (result, callback) {
- if(!callback) {
- callback = result;
- result = null;
- }
- return callback(null, !result || result.counter < 5);
- },
- function (callback) {
- count++;
- setTimeout(function() {
- callback(null, { counter: count });
- }, 1000);
- },
- function (err) {
- // 5 seconds have passed
- }
-);
-```
-
----------------------------------------
-
-<a name="doDuring"></a>
-
-### doDuring(fn, test, callback)
-
-The post-check version of [`during`](#during). To reflect the difference in
-the order of operations, the arguments `test` and `fn` are switched.
-
-Also a version of [`doWhilst`](#doWhilst) with asynchronous `test` function.
-
----------------------------------------
-
-<a name="forever"></a>
-
-### forever(fn, [errback])
-
-Calls the asynchronous function `fn` with a callback parameter that allows it to
-call itself again, in series, indefinitely.
-
-If an error is passed to the callback then `errback` is called with the
-error, and execution stops, otherwise it will never be called.
-
-```js
-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.
- }
-);
-```
-
----------------------------------------
-
-<a name="waterfall"></a>
-
-### waterfall(tasks, [callback])
-
-Runs the `tasks` array of functions in series, each passing their results to the next in
-the array. However, if any of the `tasks` pass an error to their own callback, the
-next function is not executed, and the main `callback` is immediately called with
-the error.
-
-__Arguments__
-
-* `tasks` - An array of functions to run, each function is passed a
- `callback(err, result1, result2, ...)` it must call on completion. The first
- argument is an error (which can be `null`) and any further arguments will be
- passed as arguments in order to the next task.
-* `callback(err, [results])` - An optional callback to run once all the functions
- have completed. This will be passed the results of the last task's callback.
-
-
-
-__Example__
-
-```js
-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:
-
-```js
-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');
-}
-```
-
-Or, if you need to pass any argument to the first function:
-
-```js
-async.waterfall([
- async.apply(myFirstFunction, 'zero'),
- mySecondFunction,
- myLastFunction,
-], function (err, result) {
- // result now equals 'done'
-});
-function myFirstFunction(arg1, callback) {
- // arg1 now equals 'zero'
- 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');
-}
-```
-
----------------------------------------
-
-<a name="compose"></a>
-
-### compose(fn1, fn2...)
-
-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 `f()`, `g()`, and `h()` would produce the result of
-`f(g(h()))`, only this version uses callbacks to obtain the return values.
-
-Each function is executed with the `this` binding of the composed function.
-
-__Arguments__
-
-* `functions...` - the asynchronous functions to compose
-
-
-__Example__
-
-```js
-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
-});
-```
-
----------------------------------------
-
-<a name="seq"></a>
-
-### seq(fn1, fn2...)
-
-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 [`compose`](#compose) with the arguments reversed.
-
-Each function is executed with the `this` binding of the composed function.
-
-__Arguments__
-
-* `functions...` - the asynchronous functions to compose
-
-
-__Example__
-
-```js
-// 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 });
- }
- });
-});
-```
-
----------------------------------------
-
-<a name="applyEach"></a>
-
-### applyEach(fns, args..., callback)
-
-Applies the provided arguments to each function in the array, calling
-`callback` after all functions have completed. If you only provide the first
-argument, then it will return a function which lets you pass in the
-arguments as if it were a single function call.
-
-__Arguments__
-
-* `fns` - A collection of asynchronous functions to all call with the same arguments
-* `args...` - any number of separate arguments to pass to the function
-* `callback` - the final argument should be the callback, called when all
- functions have completed processing
-
-
-__Example__
-
-```js
-async.applyEach([enableSearch, updateSchema], 'bucket', callback);
-
-// partial application example:
-async.each(
- buckets,
- async.applyEach([enableSearch, updateSchema]),
- callback
-);
-```
-
-__Related__
-
-* applyEachSeries(tasks, args..., [callback])
-
----------------------------------------
-
-<a name="queue"></a>
-
-### queue(worker, [concurrency])
-
-Creates a `queue` object with the specified `concurrency`. Tasks added to the
-`queue` are processed in parallel (up to the `concurrency` limit). If all
-`worker`s are in progress, the task is queued until one becomes available.
-Once a `worker` completes a `task`, that `task`'s callback is called.
-
-__Arguments__
-
-* `worker(task, callback)` - An asynchronous function for processing a queued
- task, which must call its `callback(err)` argument when finished, with an
- optional `error` as an argument. If you want to handle errors from an individual task, pass a callback to `q.push()`.
-* `concurrency` - An `integer` for determining how many `worker` functions should be
- run in parallel. If omitted, the concurrency defaults to `1`. If the concurrency is `0`, an error is thrown.
-
-__Queue objects__
-
-The `queue` object returned by this function has the following properties and
-methods:
-
-* `length()` - a function returning the number of items waiting to be processed.
-* `started` - a function returning whether or not any items have been pushed and processed by the queue
-* `running()` - a function returning the number of items currently being processed.
-* `workersList()` - a function returning the array of items currently being processed.
-* `idle()` - a function returning false if there are items waiting or being processed, or true if not.
-* `concurrency` - an integer for determining how many `worker` functions should be
- run in parallel. This property can be changed after a `queue` is created to
- alter the concurrency on-the-fly.
-* `push(task, [callback])` - add a new task to the `queue`. Calls `callback` once
- the `worker` has finished processing the task. Instead of a single task, a `tasks` array
- can be submitted. The respective callback is used for every task in the list.
-* `unshift(task, [callback])` - add a new task to the front of the `queue`.
-* `saturated` - a callback that is called when the number of running workers hits the `concurrency` limit, and further tasks will be queued.
-* `unsaturated` - a callback that is called when the number of running workers is less than the `concurrency` & `buffer` limits, and further tasks will not be queued.
-* `buffer` A minimum threshold buffer in order to say that the `queue` is `unsaturated`.
-* `empty` - a callback that is called when the last item from the `queue` is given to a `worker`.
-* `drain` - a callback that is called when the last item from the `queue` has returned from the `worker`.
-* `paused` - a boolean for determining whether the queue is in a paused state
-* `pause()` - a function that pauses the processing of tasks until `resume()` is called.
-* `resume()` - a function that resumes the processing of queued tasks when the queue is paused.
-* `kill()` - a function that removes the `drain` callback and empties remaining tasks from the queue forcing it to go idle.
-
-__Example__
-
-```js
-// 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');
-}
-
-// add some items to the queue
-
-q.push({name: 'foo'}, function (err) {
- console.log('finished processing foo');
-});
-q.push({name: 'bar'}, function (err) {
- console.log('finished processing 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');
-});
-```
-
----------------------------------------
-
-<a name="priorityQueue"></a>
-
-### priorityQueue(worker, concurrency)
-
-The same as [`queue`](#queue) only tasks are assigned a priority and completed in ascending priority order. There are two differences between `queue` and `priorityQueue` objects:
-
-* `push(task, priority, [callback])` - `priority` should be a number. If an array of
- `tasks` is given, all tasks will be assigned the same priority.
-* The `unshift` method was removed.
-
----------------------------------------
-
-<a name="cargo"></a>
-
-### cargo(worker, [payload])
-
-Creates a `cargo` object with the specified payload. Tasks added to the
-cargo will be processed altogether (up to the `payload` limit). If the
-`worker` is in progress, the task is queued until it becomes available. Once
-the `worker` has completed some tasks, each callback of those tasks is called.
-Check out [these](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) [animations](https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966) for how `cargo` and `queue` work.
-
-While [queue](#queue) 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.
-
-__Arguments__
-
-* `worker(tasks, callback)` - An asynchronous function for processing an array of
- queued tasks, which must call its `callback(err)` argument when finished, with
- an optional `err` argument.
-* `payload` - An optional `integer` for determining how many tasks should be
- processed per round; if omitted, the default is unlimited.
-
-__Cargo objects__
-
-The `cargo` object returned by this function has the following properties and
-methods:
-
-* `length()` - A function returning the number of items waiting to be processed.
-* `payload` - An `integer` for determining how many tasks should be
- process per round. This property can be changed after a `cargo` is created to
- alter the payload on-the-fly.
-* `push(task, [callback])` - Adds `task` to the `queue`. The callback is called
- once the `worker` has finished processing the task. Instead of a single task, an array of `tasks`
- can be submitted. The respective callback is used for every task in the list.
-* `saturated` - A callback that is called when the `queue.length()` hits the concurrency and further tasks will be queued.
-* `empty` - A callback that is called when the last item from the `queue` is given to a `worker`.
-* `drain` - A callback that is called when the last item from the `queue` has returned from the `worker`.
-* `idle()`, `pause()`, `resume()`, `kill()` - cargo inherits all of the same methods and event callbacks as [`queue`](#queue)
-
-__Example__
-
-```js
-// 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');
-});
-cargo.push({name: 'baz'}, function (err) {
- console.log('finished processing baz');
-});
-```
-
----------------------------------------
-
-<a name="auto"></a>
-
-### auto(tasks, [concurrency], [callback])
-
-Determines the best order for running the functions in `tasks`, 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.
-
-If any of the functions pass an error to their callback, the `auto` sequence will stop. Further tasks will not execute (so any other functions depending on it will not run), and the main `callback` is immediately called with the error.
-
-Functions 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.
-
-
-```js
-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);
-```
-
-
-__Arguments__
-
-* `tasks` - An object. Each of its properties is either a function or an array of requirements, with the function 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:
- * a `results` object, containing the results of the previously executed functions, only passed if the task has any dependencies, **Argument order changed in 2.0**
- * a `callback(err, result)` function, which must be called when finished, passing an `error` (which can be `null`) and the result of the function's execution. **Argument order changed in 2.0**
-* `concurrency` - An optional `integer` for determining the maximum number of tasks that can be run in parallel. By default, as many as possible.
-* `callback(err, results)` - An optional callback which is called when all the tasks have been completed. It receives the `err` argument if any `tasks` pass an error to their callback. Results are always returned; however, if an error occurs, no further `tasks` will be performed, and the results object will only contain partial results.
-
-__Example__
-
-```js
-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);
-});
-```
-
-This is a fairly trivial example, but to do this using the basic parallel and series functions would look like this:
-
-```js
-async.parallel([
- function(callback){
- console.log('in get_data');
- // async code to get some data
- callback(null, 'data', 'converted to array');
- },
- 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');
- }
-],
-function(err, results){
- async.series([
- function(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
- results.push('filename');
- callback(null);
- },
- function(callback){
- console.log('in email_link', JSON.stringify(results));
- // once the file is written let's email a link to it...
- callback(null, {'file':results.pop(), 'email':'user@example.com'});
- }
- ]);
-});
-```
-
-For a complicated series of `async` tasks, using the [`auto`](#auto) function makes adding new tasks much easier (and the code more readable).
-
----------------------------------------
-<a name="autoInject" />
-### autoInject(tasks, [callback])
-
-A dependency-injected version of the [`auto`](#auto) function. Dependent tasks are specified as parameters to the function, before 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.
-
-If a final callback is specified, the task results are still provided as a composite `results` object, exactly like auto.
-
-The autoInject function is purely syntactic sugar and its semantics are otherwise equivalent to [`auto`](#auto).
-
-__Arguments__
-
-* `tasks` - An object, each of whose properties is a function 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.
- * The `callback` parameter is a `callback(err, result)` which must be called when finished, passing an `error` (which can be `null`) 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.
-* `callback(err, results)` - An optional callback which is called when all the tasks have been completed. It receives the `err` argument if any `tasks` pass an error to their callback. Results are always returned; however, if an error occurs, no further `tasks` will be performed, and the results object will only contain partial results.
-
-
-__Example__
-
-The example from [`auto`](#auto) can be rewritten as follows:
-
-```js
-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. The final results callback can be provided as an array in the same way.
-
-```js
-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);
-});
-```
-
-This still has an advantage over plain `auto`, since the results a task depends on are still spread into arguments.
-
-
----------------------------------------
-
-<a name="retry"></a>
-
-### retry([opts = {times: 5, interval: 0}| 5], task, [callback])
-
-Attempts to get a successful response from `task` no more than `times` times before
-returning an error. If the task is successful, the `callback` 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.
-
-__Arguments__
-
-* `opts` - Can be either an object with `times` and `interval` or a number.
- * `times` - The number of attempts to make before giving up. The default is `5`.
- * `interval` - The time to wait between retries, in milliseconds. The default is `0`. The interval may also be specified as a function of the retry count (see example).
- * If `opts` is a number, the number specifies the number of times to retry, with the default interval of `0`.
-* `task(callback, results)` - A function which receives two arguments: (1) a `callback(err, result)`
- which must be called when finished, passing `err` (which can be `null`) and the `result` of
- the function's execution, and (2) a `results` object, containing the results of
- the previously executed functions (if nested inside another control flow).
-* `callback(err, results)` - An optional callback which is called when the
- task has succeeded, or after the final failed attempt. It receives the `err` and `result` arguments of the last attempt at completing the `task`. **Callback made optional in 2.0, use `retryable` for previous behavior.**
-
-The [`retry`](#retry) function can be used as a stand-alone control flow by passing a callback, as shown below:
-
-```js
-// try calling apiMethod 3 times
-async.retry(3, apiMethod, function(err, result) {
- // do something with the result
-});
-```
-
-```js
-// 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
-});
-```
-
-The interval may also be specified as a function of the retry count:
-
-```js
-// 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
-});
-```
-
-```js
-// try calling apiMethod the default 5 times no delay between each retry
-async.retry(apiMethod, function(err, result) {
- // do something with the result
-});
-```
-
-It can also be embedded within other control flow functions to retry individual methods
-that are not as reliable, like this:
-
-```js
-async.auto({
- users: api.getUsers.bind(api),
- payments: async.retry(3, api.getPayments.bind(api))
-}, function(err, results) {
- // do something with the results
-});
-```
-
-
----------------------------------------
-
-<a name="retryable"></a>
-
-### retryable([opts = {times: 5, interval: 0}| 5], task)
-
-A close relative of `retry`. This method wraps a task and makes it retryable, rather than immediately calling it with retries.
-
-__Arguments__
-
-* `opts` - optional options, exactly the same as from `retry`
-* `task` - the asynchronous function to wrap
-
-__Example__
-
-```js
-async.auto({
- dep1: async.retryable(3, getFromFlakyService),
- process: ["dep1", async.retryable(3, function (results, cb) {
- maybeProcessData(results.dep1, cb)
- })]
-}, callback)
-```
-
----------------------------------------
-
-<a name="iterator"></a>
-
-### iterator(tasks)
-
-Creates an iterator function which calls the next function in the `tasks` array,
-returning a continuation to call the next one after that. It's also possible to
-“peek” at the next iterator with `iterator.next()`.
-
-This function is used internally by the `async` module, but can be useful when
-you want to manually control the flow of functions in series.
-
-__Arguments__
-
-* `tasks` - An array of functions to run.
-
-__Example__
-
-```js
-var iterator = async.iterator([
- function(){ sys.p('one'); },
- function(){ sys.p('two'); },
- function(){ sys.p('three'); }
-]);
-
-node> var iterator2 = iterator();
-'one'
-node> var iterator3 = iterator2();
-'two'
-node> iterator3();
-'three'
-node> var nextfn = iterator2.next();
-node> nextfn();
-'three'
-```
-
-## Utils
-
-<a name="apply"></a>
-
-### apply(function, arguments..)
-
-Creates a continuation function with some arguments already applied.
-
-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.
-
-__Arguments__
-
-* `function` - The function you want to eventually apply all arguments to.
-* `arguments...` - Any number of arguments to automatically apply when the
- continuation is called.
-
-__Example__
-
-```js
-// 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:
-
-```js
-node> var fn = async.apply(sys.puts, 'one');
-node> fn('two', 'three');
-one
-two
-three
-```
-
----------------------------------------
-
-<a name="nextTick"></a>
-
-### nextTick(callback, [args...]), setImmediate(callback, [args...])
-
-Calls `callback` on a later loop around the event loop. In Node.js this just calls `setImmediate`. In the browser it will use `setImmediate` if available, otherwise `setTimeout(callback, 0)`, which means other higher priority events may precede the execution of `callback`.
-
-This is used internally for browser-compatibility purposes.
-
-__Arguments__
-
-* `callback` - The function to call on a later loop around the event loop.
-* `args...` - any number of additional arguments to pass to the callback on the next tick
-
-__Example__
-
-```js
-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)
-```
-
----------------------------------------
-
-<a name="times"></a>
-
-### times(n, iteratee, [callback])
-
-Calls the `iteratee` function `n` times, and accumulates results in the same manner
-you would use with [`map`](#map).
-
-__Arguments__
-
-* `n` - The number of times to run the function.
-* `iteratee` - The function to call `n` times.
-* `callback` - see [`map`](#map)
-
-__Example__
-
-```js
-// 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
-});
-```
-
-__Related__
-
-* timesSeries(n, iteratee, [callback])
-* timesLimit(n, limit, iteratee, [callback])
-
----------------------------------------
-
-<a name="race"></a>
-### race(tasks, [callback])
-
-Runs the `tasks` array of functions in parallel, without waiting until the
-previous function has completed. Once any the `tasks` completed or pass an
-error to its callback, the main `callback` is immediately called. It's
-equivalent to `Promise.race()`.
-
-__Arguments__
-
-* `tasks` - An array containing functions to run. Each function is passed
- a `callback(err, result)` which it must call on completion with an error `err`
- (which can be `null`) and an optional `result` value.
-* `callback(err, result)` - A callback to run once any of the
- functions have completed. This function gets an error or result from the
- first function that completed.
-
-__Example__
-
-```js
-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
-});
-```
-
----------------------------------------
-
-<a name="memoize"></a>
-
-### memoize(fn, [hasher])
-
-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.
-
-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.
-
-The cache of results is exposed as the `memo` property of the function returned
-by `memoize`.
-
-__Arguments__
-
-* `fn` - The function to proxy and cache results from.
-* `hasher` - 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.
-
-__Example__
-
-```js
-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
-});
-```
-
----------------------------------------
-
-<a name="unmemoize"></a>
-
-### unmemoize(fn)
-
-Undoes a [`memoize`](#memoize)d function, reverting it to the original, unmemoized
-form. Handy for testing.
-
-__Arguments__
-
-* `fn` - the memoized function
-
----------------------------------------
-
-<a name="ensureAsync"></a>
-
-### ensureAsync(fn)
-
-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 (`RangeError: Maximum call stack size exceeded`) and generally keeping [Zalgo](http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony) contained.
-
-__Arguments__
-
-* `fn` - an async function, one that expects a node-style callback as its last argument
-
-Returns a wrapped function with the exact same call signature as the function passed in.
-
-__Example__
-
-```js
-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);
-
-```
-
----------------------------------------
-
-<a name="constant"></a>
-
-### constant(values...)
-
-Returns a function that when called, calls-back with the values provided. Useful as the first function in a `waterfall`, or for plugging values in to `auto`.
-
-__Example__
-
-```js
-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);
-
-```
-
----------------------------------------
-
-<a name="asyncify"></a>
-<a name="wrapSync"></a>
-
-### asyncify(func)
-
-__Alias:__ `wrapSync`
-
-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.
-
-__Example__
-
-```js
-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)
-```
-
-If the function passed to `asyncify` returns a Promise, that promises's resolved/rejected state will be used to call the callback, rather than simply the synchronous return value. Example:
-
-```js
-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)
-```
-
-This also means you can asyncify ES2016 `async` functions.
-
-```js
-var q = async.queue(async.asyncify(async function (file) {
- var intermediateStep = await processFile(file);
- return await somePromise(intermediateStep)
-}));
-
-q.push(files);
-```
-
----------------------------------------
-
-<a name="log"></a>
-
-### log(function, arguments)
-
-Logs the result of an `async` function to the `console`. Only works in Node.js or
-in browsers that support `console.log` and `console.error` (such as FF and Chrome).
-If multiple arguments are returned from the async function, `console.log` is
-called on each argument in order.
-
-__Arguments__
-
-* `function` - The function you want to eventually apply all arguments to.
-* `arguments...` - Any number of arguments to apply to the function.
-
-__Example__
-
-```js
-var hello = function(name, callback){
- setTimeout(function(){
- callback(null, 'hello ' + name);
- }, 1000);
-};
-```
-```js
-node> async.log(hello, 'world');
-'hello world'
-```
-
----------------------------------------
-
-<a name="dir"></a>
-
-### dir(function, arguments)
-
-Logs the result of an `async` function to the `console` using `console.dir` to
-display the properties of the resulting object. Only works in Node.js or
-in browsers that support `console.dir` and `console.error` (such as FF and Chrome).
-If multiple arguments are returned from the async function, `console.dir` is
-called on each argument in order.
-
-__Arguments__
-
-* `function` - The function you want to eventually apply all arguments to.
-* `arguments...` - Any number of arguments to apply to the function.
-
-__Example__
-
-```js
-var hello = function(name, callback){
- setTimeout(function(){
- callback(null, {hello: name});
- }, 1000);
-};
-```
-```js
-node> async.dir(hello, 'world');
-{hello: 'world'}
-```
-
----------------------------------------
-
-<a name="noConflict"></a>
-
-### noConflict()
-
-Changes the value of `async` back to its original value, returning a reference to the
-`async` object.
-
----------------------------------------
-
-<a name="timeout"></a>
-
-### timeout(function, miliseconds)
-
-Sets a time limit on an asynchronous function. If the function does not call its callback within the specified miliseconds, it will be called with a timeout error. The code property for the error object will be `'ETIMEDOUT'`.
-
-Returns a wrapped function that can be used with any of the control flow functions.
-
-__Arguments__
-
-* `function` - The asynchronous function you want to set the time limit.
-* `miliseconds` - The specified time limit.
-* `info` - *Optional* Any variable you want attached (`string`, `object`, etc) to
- timeout Error for more information.
-
-__Example__
-
-```js
-async.timeout(function nameOfCallback(callback) {
- doAsyncTask(callback);
-}, 1000, 'more info about timeout');
-```
-
----------------------------------------
-
-<a name="reflect"></a>
-### reflect(function)
-
-Wraps the function in another function that always returns data even when it errors.
-The object returned has either the property `error` or `value`.
-
-__Arguments__
-
-* `function` - The function you want to wrap
-
-__Example__
-
-```js
-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'
-});
-```
-
----------------------------------------
-
-<a name="reflectAll"></a>
-### reflectAll(tasks)
-
-A helper function that wraps an array of functions with reflect.
-
-__Arguments__
-
-* `tasks` - The array of functions to wrap in reflect.
-
-__Example__
-
-```javascript
-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'
-});
-```
diff --git a/lib/apply.js b/lib/apply.js
index 1cf7cb3..465ed10 100644
--- a/lib/apply.js
+++ b/lib/apply.js
@@ -9,7 +9,8 @@ import rest from 'lodash/rest';
*
* @name apply
* @static
- * @memberOf async
+ * @memberOf module:Utils
+ * @method
* @category Util
* @param {Function} function - The function you want to eventually apply all
* arguments to. Invokes with (arguments...).
diff --git a/lib/applyEach.js b/lib/applyEach.js
index 3337f57..c106114 100644
--- a/lib/applyEach.js
+++ b/lib/applyEach.js
@@ -9,7 +9,8 @@ import map from './map';
*
* @name applyEach
* @static
- * @memberOf async
+ * @memberOf module:ControlFlow
+ * @method
* @category Control Flow
* @param {Array|Object} fns - A collection of asynchronous functions to all
* call with the same arguments
diff --git a/lib/applyEachSeries.js b/lib/applyEachSeries.js
index 0a01891..f0919cb 100644
--- a/lib/applyEachSeries.js
+++ b/lib/applyEachSeries.js
@@ -2,12 +2,13 @@ import applyEach from './internal/applyEach';
import mapSeries from './mapSeries';
/**
- * The same as `applyEach` but runs only a single async operation at a time.
+ * The same as [`applyEach`]{@link module:ControlFlow.applyEach} but runs only a single async operation at a time.
*
* @name applyEachSeries
* @static
- * @memberOf async
- * @see async.applyEach
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.applyEach]{@link module:ControlFlow.applyEach}
* @category Control Flow
* @param {Array|Object} fns - A collection of asynchronous functions to all
* call with the same arguments
diff --git a/lib/asyncify.js b/lib/asyncify.js
index 089f94b..dec39d2 100644
--- a/lib/asyncify.js
+++ b/lib/asyncify.js
@@ -16,7 +16,8 @@ import initialParams from './internal/initialParams';
*
* @name asyncify
* @static
- * @memberOf async
+ * @memberOf module:Utils
+ * @method
* @alias wrapSync
* @category Util
* @param {Function} func - The synchronous function to convert to an
diff --git a/lib/auto.js b/lib/auto.js
index bb8ee87..ce9f259 100644
--- a/lib/auto.js
+++ b/lib/auto.js
@@ -26,7 +26,8 @@ import onlyOnce from './internal/onlyOnce';
*
* @name auto
* @static
- * @memberOf async
+ * @memberOf module:ControlFlow
+ * @method
* @category Control Flow
* @param {Object} tasks - An object. Each of its properties is either a
* function or an array of requirements, with the function itself the last item
diff --git a/lib/autoInject.js b/lib/autoInject.js
index 96922ba..31bd622 100644
--- a/lib/autoInject.js
+++ b/lib/autoInject.js
@@ -21,7 +21,7 @@ function parseParams(func) {
}
/**
- * A dependency-injected version of the {@link async.auto} function. Dependent
+ * A dependency-injected version of the [async.auto]{@link module:ControlFlow.auto} 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
@@ -31,12 +31,13 @@ function parseParams(func) {
* specified as named parameters after the initial error parameter.
*
* The autoInject function is purely syntactic sugar and its semantics are
- * otherwise equivalent to {@link async.auto}.
+ * otherwise equivalent to [async.auto]{@link module:ControlFlow.auto}.
*
* @name autoInject
* @static
- * @memberOf async
- * @see async.auto
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.auto]{@link module:ControlFlow.auto}
* @category Control Flow
* @param {Object} tasks - An object, each of whose properties is a function of
* the form 'func([dependencies...], callback). The object's key of a property
diff --git a/lib/cargo.js b/lib/cargo.js
index 01329e7..d86cb67 100644
--- a/lib/cargo.js
+++ b/lib/cargo.js
@@ -2,17 +2,18 @@ import queue from './internal/queue';
/**
* A cargo of tasks for the worker function to complete. Cargo inherits all of
- * the same methods and event callbacks as {@link async.queue}.
- * @typedef {Object} cargo
+ * the same methods and event callbacks as [`queue`]{@link module:ControlFlow.queue}.
+ * @typedef {Object} CargoObject
+ * @memberOf module:ControlFlow
* @property {Function} length - A function returning the number of items
- * waiting to be processed. Invoke with ().
+ * waiting to be processed. Invoke like `cargo.length()`.
* @property {number} payload - An `integer` for determining how many tasks
* should be process per round. This property can be changed after a `cargo` is
* created to alter the payload on-the-fly.
* @property {Function} push - Adds `task` to the `queue`. The callback is
* called once the `worker` has finished processing the task. Instead of a
* single task, an array of `tasks` can be submitted. The respective callback is
- * used for every task in the list. Invoke with (task, [callback]).
+ * used for every task in the list. Invoke like `cargo.push(task, [callback])`.
* @property {Function} saturated - A callback that is called when the
* `queue.length()` hits the concurrency and further tasks will be queued.
* @property {Function} empty - A callback that is called when the last item
@@ -20,13 +21,13 @@ import queue from './internal/queue';
* @property {Function} drain - A callback that is called when the last item
* from the `queue` has returned from the `worker`.
* @property {Function} idle - a function returning false if there are items
- * waiting or being processed, or true if not. Invoke with ().
+ * waiting or being processed, or true if not. Invoke like `cargo.idle()`.
* @property {Function} pause - a function that pauses the processing of tasks
- * until `resume()` is called. Invoke with ().
+ * until `resume()` is called. Invoke like `cargo.pause()`.
* @property {Function} resume - a function that resumes the processing of
- * queued tasks when the queue is paused. Invoke with ().
+ * queued tasks when the queue is paused. Invoke like `cargo.resume()`.
* @property {Function} kill - a function that removes the `drain` callback and
- * empties remaining tasks from the queue forcing it to go idle. Invoke with ().
+ * empties remaining tasks from the queue forcing it to go idle. Invoke like `cargo.kill()`.
*/
/**
@@ -37,22 +38,23 @@ import queue from './internal/queue';
* called. Check out [these](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) [animations](https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966)
* for how `cargo` and `queue` work.
*
- * While [queue](#queue) passes only one task to one of a group of workers
+ * While [`queue`]{@link module:ControlFlow.queue} 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.
*
* @name cargo
* @static
- * @memberOf async
- * @see async.queue
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.queue]{@link module:ControlFlow.queue}
* @category Control Flow
* @param {Function} worker - An asynchronous function for processing an array
* of queued tasks, which must call its `callback(err)` argument when finished,
- * with an optional `err` argument. Invoked with (tasks, callback).
+ * with an optional `err` argument. Invoked with `(tasks, callback)`.
* @param {number} [payload=Infinity] - An optional `integer` for determining
* how many tasks should be processed per round; if omitted, the default is
* unlimited.
- * @returns {cargo} A cargo object to manage the tasks. Callbacks can
+ * @returns {module:ControlFlow.CargoObject} 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.
* @example
diff --git a/lib/compose.js b/lib/compose.js
index 227c2ea..ff2e0ab 100644
--- a/lib/compose.js
+++ b/lib/compose.js
@@ -12,7 +12,8 @@ var reverse = Array.prototype.reverse;
*
* @name compose
* @static
- * @memberOf async
+ * @memberOf module:ControlFlow
+ * @method
* @category Control Flow
* @param {...Function} functions - the asynchronous functions to compose
* @returns {Function} an asynchronous function that is the composed
diff --git a/lib/concat.js b/lib/concat.js
index be7410d..db23737 100644
--- a/lib/concat.js
+++ b/lib/concat.js
@@ -10,7 +10,8 @@ import doParallel from './internal/doParallel';
*
* @name concat
* @static
- * @memberOf async
+ * @memberOf module:Collections
+ * @method
* @category Collection
* @param {Array|Object} coll - A collection to iterate over.
* @param {Function} iteratee - A function to apply to each item in `coll`.
diff --git a/lib/concatSeries.js b/lib/concatSeries.js
index fef87b7..c5dfb61 100644
--- a/lib/concatSeries.js
+++ b/lib/concatSeries.js
@@ -2,12 +2,13 @@ import concat from './internal/concat';
import doSeries from './internal/doSeries';
/**
- * The same as `concat` but runs only a single async operation at a time.
+ * The same as [`concat`]{@link module:Collections.concat} but runs only a single async operation at a time.
*
* @name concatSeries
* @static
- * @memberOf async
- * @see async.concat
+ * @memberOf module:Collections
+ * @method
+ * @see [async.concat]{@link module:Collections.concat}
* @category Collection
* @param {Array|Object} coll - A collection to iterate over.
* @param {Function} iteratee - A function to apply to each item in `coll`.
diff --git a/lib/constant.js b/lib/constant.js
index a5e32fa..c7dd50f 100644
--- a/lib/constant.js
+++ b/lib/constant.js
@@ -3,12 +3,13 @@ import initialParams from './internal/initialParams';
/**
* Returns a function that when called, calls-back with the values provided.
- * Useful as the first function in a `waterfall`, or for plugging values in to
- * `auto`.
+ * Useful as the first function in a [`waterfall`]{@link module:ControlFlow.waterfall}, or for plugging values in to
+ * [`auto`]{@link module:ControlFlow.auto}.
*
* @name constant
* @static
- * @memberOf async
+ * @memberOf module:Utils
+ * @method
* @category Util
* @param {...*} arguments... - Any number of arguments to automatically invoke
* callback with.
diff --git a/lib/detect.js b/lib/detect.js
index a4e246c..3aff790 100644
--- a/lib/detect.js
+++ b/lib/detect.js
@@ -12,13 +12,14 @@ import findGetResult from './internal/findGetResult';
* that passes the test.
* If order within the original `coll` is important, then look at
- * `detectSeries`.
+ * [`detectSeries`]{@link module:Collections.detectSeries}.
*
* @name detect
* @static
- * @memberOf async
+ * @memberOf module:Collections
+ * @method
* @alias find
- * @category Collection
+ * @category Collections
* @param {Array|Object} coll - A collection to iterate over.
* @param {Function} iteratee - A truth test to apply to each item in `coll`.
* The iteratee is passed a `callback(err, truthValue)` which must be called
diff --git a/lib/detectLimit.js b/lib/detectLimit.js
index 2e8ba7a..da54bd6 100644
--- a/lib/detectLimit.js
+++ b/lib/detectLimit.js
@@ -5,15 +5,16 @@ import eachOfLimit from './eachOfLimit';
import findGetResult from './internal/findGetResult';
/**
- * The same as `detect` but runs a maximum of `limit` async operations at a
+ * The same as [`detect`]{@link module:Collections.detect} but runs a maximum of `limit` async operations at a
* time.
*
* @name detectLimit
* @static
- * @memberOf async
- * @see async.detect
+ * @memberOf module:Collections
+ * @method
+ * @see [async.detect]{@link module:Collections.detect}
* @alias findLimit
- * @category Collection
+ * @category Collections
* @param {Array|Object} coll - A collection to iterate over.
* @param {number} limit - The maximum number of async operations at a time.
* @param {Function} iteratee - A truth test to apply to each item in `coll`.
diff --git a/lib/detectSeries.js b/lib/detectSeries.js
index 59b34a5..fd29343 100644
--- a/lib/detectSeries.js
+++ b/lib/detectSeries.js
@@ -5,14 +5,15 @@ import eachOfSeries from './eachOfSeries';
import findGetResult from './internal/findGetResult';
/**
- * The same as `detect` but runs only a single async operation at a time.
+ * The same as [`detect`]{@link module:Collections.detect} but runs only a single async operation at a time.
*
* @name detectSeries
* @static
- * @memberOf async
- * @see async.detect
+ * @memberOf module:Collections
+ * @method
+ * @see [async.detect]{@link module:Collections.detect}
* @alias findSeries
- * @category Collection
+ * @category Collections
* @param {Array|Object} coll - A collection to iterate over.
* @param {Function} iteratee - A truth test to apply to each item in `coll`.
* The iteratee is passed a `callback(err, truthValue)` which must be called
diff --git a/lib/dir.js b/lib/dir.js
index 8b467af..912b558 100644
--- a/lib/dir.js
+++ b/lib/dir.js
@@ -7,9 +7,10 @@ import consoleFunc from './internal/consoleFunc';
* Chrome). If multiple arguments are returned from the async function,
* `console.dir` is called on each argument in order.
*
- * @name log
+ * @name dir
* @static
- * @memberOf async
+ * @memberOf module:Utils
+ * @method
* @category Util
* @param {Function} function - The function you want to eventually apply all
* arguments to.
diff --git a/lib/doDuring.js b/lib/doDuring.js
index e018fe4..d12d668 100644
--- a/lib/doDuring.js
+++ b/lib/doDuring.js
@@ -1,14 +1,15 @@
import during from './during';
/**
- * The post-check version of {@link async.during}. To reflect the difference in
+ * The post-check version of [`during`]{@link module:ControlFlow.during}. To reflect the difference in
* the order of operations, the arguments `test` and `fn` are switched.
*
- * Also a version of {@link async.doWhilst} with asynchronous `test` function.
+ * Also a version of [`doWhilst`]{@link module:ControlFlow.doWhilst} with asynchronous `test` function.
* @name doDuring
* @static
- * @memberOf async
- * @see async.during
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.during]{@link module:ControlFlow.during}
* @category Control Flow
* @param {Function} fn - A function which is called each time `test` passes.
* The function is passed a `callback(err)`, which must be called once it has
diff --git a/lib/doUntil.js b/lib/doUntil.js
index 01f114c..0c5bb71 100644
--- a/lib/doUntil.js
+++ b/lib/doUntil.js
@@ -1,13 +1,14 @@
import doWhilst from './doWhilst';
/**
- * Like {@link async.doWhilst}, except the `test` is inverted. Note the
+ * Like ['doWhilst']{@link module:ControlFlow.doWhilst}, except the `test` is inverted. Note the
* argument ordering differs from `until`.
*
* @name doUntil
* @static
- * @memberOf async
- * @see async.doWhilst
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.doWhilst]{@link module:ControlFlow.doWhilst}
* @category Control Flow
* @param {Function} fn - A function which is called each time `test` fails.
* The function is passed a `callback(err)`, which must be called once it has
diff --git a/lib/doWhilst.js b/lib/doWhilst.js
index 96c4664..a425999 100644
--- a/lib/doWhilst.js
+++ b/lib/doWhilst.js
@@ -1,15 +1,16 @@
import whilst from './whilst';
/**
- * The post-check version of {@link async.whilst}. To reflect the difference in
+ * The post-check version of [`whilst`]{@link module:ControlFlow.whilst}. To reflect the difference in
* the order of operations, the arguments `test` and `fn` are switched.
*
* `doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript.
*
* @name doWhilst
* @static
- * @memberOf async
- * @see async.whilst
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.whilst]{@link module:ControlFlow.whilst}
* @category Control Flow
* @param {Function} fn - A function which is called each time `test` passes.
* The function is passed a `callback(err)`, which must be called once it has
diff --git a/lib/during.js b/lib/during.js
index 1013bc8..55af1b9 100644
--- a/lib/during.js
+++ b/lib/during.js
@@ -2,15 +2,16 @@ import noop from 'lodash/noop';
import rest from 'lodash/rest';
/**
- * Like {@link async.whilst}, except the `test` is an asynchronous function that
+ * Like [`whilst`]{@link module:ControlFlow.whilst}, except the `test` is an asynchronous function that
* is passed a callback in the form of `function (err, truth)`. If error is
* passed to `test` or `fn`, the main callback is immediately called with the
* value of the error.
*
* @name during
* @static
- * @memberOf async
- * @see async.whilst
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.whilst]{@link module:ControlFlow.whilst}
* @category Control Flow
* @param {Function} test - asynchronous truth test to perform before each
* execution of `fn`. Invoked with (callback).
diff --git a/lib/each.js b/lib/each.js
index 90ba3ee..aab1d3d 100644
--- a/lib/each.js
+++ b/lib/each.js
@@ -13,7 +13,8 @@ import doLimit from './internal/doLimit';
*
* @name each
* @static
- * @memberOf async
+ * @memberOf module:Collections
+ * @method
* @alias forEach
* @category Collection
* @param {Array|Object} coll - A collection to iterate over.
diff --git a/lib/eachLimit.js b/lib/eachLimit.js
index d5f200c..a46eb9d 100644
--- a/lib/eachLimit.js
+++ b/lib/eachLimit.js
@@ -2,12 +2,13 @@ import eachOfLimit from './internal/eachOfLimit';
import withoutIndex from './internal/withoutIndex';
/**
- * The same as `each` but runs a maximum of `limit` async operations at a time.
+ * The same as [`each`]{@link module:Collections.each} but runs a maximum of `limit` async operations at a time.
*
* @name eachLimit
* @static
- * @memberOf async
- * @see async.each
+ * @memberOf module:Collections
+ * @method
+ * @see [async.each]{@link module:Collections.each}
* @alias forEachLimit
* @category Collection
* @param {Array|Object} coll - A colleciton to iterate over.
diff --git a/lib/eachOf.js b/lib/eachOf.js
index 1defd47..b51fefb 100644
--- a/lib/eachOf.js
+++ b/lib/eachOf.js
@@ -2,14 +2,16 @@ import eachOfLimit from './eachOfLimit';
import doLimit from './internal/doLimit';
/**
- * Like `each`, except that it passes the key (or index) as the second argument
+ * Like [`each`]{@link module:Collections.each}, except that it passes the key (or index) as the second argument
* to the iteratee.
*
* @name eachOf
* @static
- * @memberOf async
+ * @memberOf module:Collections
+ * @method
* @alias forEachOf
* @category Collection
+ * @see [async.each]{@link module:Collections.each}
* @param {Array|Object} coll - A collection to iterate over.
* @param {Function} iteratee - A function to apply to each
* item in `coll`. The `key` is the item's key, or index in the case of an
diff --git a/lib/eachOfLimit.js b/lib/eachOfLimit.js
index 5810f8f..55d60e3 100644
--- a/lib/eachOfLimit.js
+++ b/lib/eachOfLimit.js
@@ -1,13 +1,14 @@
import _eachOfLimit from './internal/eachOfLimit';
/**
- * The same as `eachOf` but runs a maximum of `limit` async operations at a
+ * The same as [`eachOf`]{@link module:Collections.eachOf} but runs a maximum of `limit` async operations at a
* time.
*
* @name eachOfLimit
* @static
- * @memberOf async
- * @see async.eachOf
+ * @memberOf module:Collections
+ * @method
+ * @see [async.eachOf]{@link module:Collections.eachOf}
* @alias forEachOfLimit
* @category Collection
* @param {Array|Object} coll - A collection to iterate over.
diff --git a/lib/eachOfSeries.js b/lib/eachOfSeries.js
index dee4838..32003a8 100644
--- a/lib/eachOfSeries.js
+++ b/lib/eachOfSeries.js
@@ -2,12 +2,13 @@ import eachOfLimit from './eachOfLimit';
import doLimit from './internal/doLimit';
/**
- * The same as `eachOf` but runs only a single async operation at a time.
+ * The same as [`eachOf`]{@link module:Collections.eachOf} but runs only a single async operation at a time.
*
* @name eachOfSeries
* @static
- * @memberOf async
- * @see async.eachOf
+ * @memberOf module:Collections
+ * @method
+ * @see [async.eachOf]{@link module:Collections.eachOf}
* @alias forEachOfSeries
* @category Collection
* @param {Array|Object} coll - A collection to iterate over.
diff --git a/lib/eachSeries.js b/lib/eachSeries.js
index 3d8af62..1b8e589 100644
--- a/lib/eachSeries.js
+++ b/lib/eachSeries.js
@@ -2,12 +2,13 @@ import eachLimit from './eachLimit';
import doLimit from './internal/doLimit';
/**
- * The same as `each` but runs only a single async operation at a time.
+ * The same as [`each`]{@link module:Collections.each} but runs only a single async operation at a time.
*
* @name eachSeries
* @static
- * @memberOf async
- * @see async.each
+ * @memberOf module:Collections
+ * @method
+ * @see [async.each]{@link module:Collections.each}
* @alias forEachSeries
* @category Collection
* @param {Array|Object} coll - A collection to iterate over.
diff --git a/lib/ensureAsync.js b/lib/ensureAsync.js
index 55d59fe..c60d07e 100644
--- a/lib/ensureAsync.js
+++ b/lib/ensureAsync.js
@@ -11,7 +11,8 @@ import initialParams from './internal/initialParams';
*
* @name ensureAsync
* @static
- * @memberOf async
+ * @memberOf module:Utils
+ * @method
* @category Util
* @param {Function} fn - an async function, one that expects a node-style
* callback as its last argument.
diff --git a/lib/every.js b/lib/every.js
index a2377ea..147c54a 100644
--- a/lib/every.js
+++ b/lib/every.js
@@ -7,7 +7,8 @@ import doLimit from './internal/doLimit';
*
* @name every
* @static
- * @memberOf async
+ * @memberOf module:Collections
+ * @method
* @alias all
* @category Collection
* @param {Array|Object} coll - A collection to iterate over.
diff --git a/lib/everyLimit.js b/lib/everyLimit.js
index 7d2b042..1ba2858 100644
--- a/lib/everyLimit.js
+++ b/lib/everyLimit.js
@@ -3,12 +3,13 @@ import eachOfLimit from './eachOfLimit';
import notId from './internal/notId';
/**
- * The same as `every` but runs a maximum of `limit` async operations at a time.
+ * The same as [`every`]{@link module:Collections.every} but runs a maximum of `limit` async operations at a time.
*
* @name everyLimit
* @static
- * @memberOf async
- * @see async.every
+ * @memberOf module:Collections
+ * @method
+ * @see [async.every]{@link module:Collections.every}
* @alias allLimit
* @category Collection
* @param {Array|Object} coll - A collection to iterate over.
diff --git a/lib/everySeries.js b/lib/everySeries.js
index 24ee4ed..3cdadf0 100644
--- a/lib/everySeries.js
+++ b/lib/everySeries.js
@@ -2,12 +2,13 @@ import everyLimit from './everyLimit';
import doLimit from './internal/doLimit';
/**
- * The same as `every` but runs only a single async operation at a time.
+ * The same as [`every`]{@link module:Collections.every} but runs only a single async operation at a time.
*
* @name everySeries
* @static
- * @memberOf async
- * @see async.every
+ * @memberOf module:Collections
+ * @method
+ * @see [async.every]{@link module:Collections.every}
* @alias allSeries
* @category Collection
* @param {Array|Object} coll - A collection to iterate over.
diff --git a/lib/filter.js b/lib/filter.js
index 7f48ae1..b858fea 100644
--- a/lib/filter.js
+++ b/lib/filter.js
@@ -8,7 +8,8 @@ import doLimit from './internal/doLimit';
*
* @name filter
* @static
- * @memberOf async
+ * @memberOf module:Collections
+ * @method
* @alias select
* @category Collection
* @param {Array|Object} coll - A collection to iterate over.
diff --git a/lib/filterLimit.js b/lib/filterLimit.js
index 615b170..6d429e8 100644
--- a/lib/filterLimit.js
+++ b/lib/filterLimit.js
@@ -2,13 +2,14 @@ import filter from './internal/filter';
import doParallelLimit from './internal/doParallelLimit';
/**
- * The same as `filter` but runs a maximum of `limit` async operations at a
+ * The same as [`filter`]{@link module:Collections.filter} but runs a maximum of `limit` async operations at a
* time.
*
* @name filterLimit
* @static
- * @memberOf async
- * @see async.filter
+ * @memberOf module:Collections
+ * @method
+ * @see [async.filter]{@link module:Collections.filter}
* @alias selectLimit
* @category Collection
* @param {Array|Object} coll - A collection to iterate over.
diff --git a/lib/filterSeries.js b/lib/filterSeries.js
index 6fde694..781e4eb 100644
--- a/lib/filterSeries.js
+++ b/lib/filterSeries.js
@@ -2,12 +2,13 @@ import filterLimit from './filterLimit';
import doLimit from './internal/doLimit';
/**
- * The same as `filter` but runs only a single async operation at a time.
+ * The same as [`filter`]{@link module:Collections.filter} but runs only a single async operation at a time.
*
* @name filterSeries
* @static
- * @memberOf async
- * @see async.filter
+ * @memberOf module:Collections
+ * @method
+ * @see [async.filter]{@link module:Collections.filter}
* @alias selectSeries
* @category Collection
* @param {Array|Object} coll - A collection to iterate over.
diff --git a/lib/forever.js b/lib/forever.js
index 4708d21..0147395 100644
--- a/lib/forever.js
+++ b/lib/forever.js
@@ -13,7 +13,8 @@ import ensureAsync from './ensureAsync';
*
* @name forever
* @static
- * @memberOf async
+ * @memberOf module:ControlFlow
+ * @method
* @category Control Flow
* @param {Function} fn - a function to call repeatedly. Invoked with (next).
* @param {Function} [errback] - when `fn` passes an error to it's callback,
diff --git a/lib/index.js b/lib/index.js
index 091f657..28b87d6 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -5,6 +5,22 @@
* `npm install --save async`, it can also be used directly in the browser.
* @module async
*/
+
+/**
+ * A collection of `async` functions for manipulating collections, such as
+ * arrays and objects.
+ * @module Collections
+ */
+
+/**
+ * A collection of `async` functions for controlling the flow through a script.
+ * @module ControlFlow
+ */
+
+ /**
+ * A collection of `async` utility functions.
+ * @module Utils
+ */
import applyEach from './applyEach';
import applyEachSeries from './applyEachSeries';
import apply from './apply';
diff --git a/lib/iterator.js b/lib/iterator.js
index b37c18a..fafd960 100644
--- a/lib/iterator.js
+++ b/lib/iterator.js
@@ -8,7 +8,8 @@
*
* @name iterator
* @static
- * @memberOf async
+ * @memberOf module:ControlFlow
+ * @method
* @category Control Flow
* @param {Array} tasks - An array of functions to run.
* @returns The next function to run in the series.
diff --git a/lib/log.js b/lib/log.js
index b18733e..848661d 100644
--- a/lib/log.js
+++ b/lib/log.js
@@ -8,7 +8,8 @@ import consoleFunc from './internal/consoleFunc';
*
* @name log
* @static
- * @memberOf async
+ * @memberOf module:Utils
+ * @method
* @category Util
* @param {Function} function - The function you want to eventually apply all
* arguments to.
diff --git a/lib/map.js b/lib/map.js
index 19642c8..24af6fb 100644
--- a/lib/map.js
+++ b/lib/map.js
@@ -20,7 +20,8 @@ import doLimit from './internal/doLimit';
*
* @name map
* @static
- * @memberOf async
+ * @memberOf module:Collections
+ * @method
* @category Collection
* @param {Array|Object} coll - A collection to iterate over.
* @param {Function} iteratee - A function to apply to each item in `coll`.
diff --git a/lib/mapLimit.js b/lib/mapLimit.js
index 0cf049b..efaff2b 100644
--- a/lib/mapLimit.js
+++ b/lib/mapLimit.js
@@ -2,12 +2,13 @@ import doParallelLimit from './internal/doParallelLimit';
import map from './internal/map';
/**
- * The same as `map` but runs a maximum of `limit` async operations at a time.
+ * The same as [`map`]{@link module:Collections.map} but runs a maximum of `limit` async operations at a time.
*
* @name mapLimit
* @static
- * @memberOf async
- * @see async.map
+ * @memberOf module:Collections
+ * @method
+ * @see [async.map]{@link module:Collections.map}
* @category Collection
* @param {Array|Object} coll - A collection to iterate over.
* @param {number} limit - The maximum number of async operations at a time.
diff --git a/lib/mapSeries.js b/lib/mapSeries.js
index c241bef..24ce126 100644
--- a/lib/mapSeries.js
+++ b/lib/mapSeries.js
@@ -2,12 +2,13 @@ import mapLimit from './mapLimit';
import doLimit from './internal/doLimit';
/**
- * The same as `map` but runs only a single async operation at a time.
+ * The same as [`map`]{@link module:Collections.map} but runs only a single async operation at a time.
*
* @name mapSeries
* @static
- * @memberOf async
- * @see async.map
+ * @memberOf module:Collections
+ * @method
+ * @see [async.map]{@link module:Collections.map}
* @category Collection
* @param {Array|Object} coll - A collection to iterate over.
* @param {Function} iteratee - A function to apply to each item in `coll`.
diff --git a/lib/mapValues.js b/lib/mapValues.js
index 83ffc43..240fc67 100644
--- a/lib/mapValues.js
+++ b/lib/mapValues.js
@@ -3,7 +3,7 @@ import doLimit from './internal/doLimit';
/**
- * A relative of `map`, designed for use with objects.
+ * A relative of [`map`]{@link module:Collections.map}, designed for use with objects.
*
* Produces a new Object by mapping each value of `obj` through the `iteratee`
* function. The `iteratee` is called each `value` and `key` from `obj` and a
@@ -17,7 +17,8 @@ import doLimit from './internal/doLimit';
*
* @name mapValues
* @static
- * @memberOf async
+ * @memberOf module:Collections
+ * @method
* @category Collection
* @param {Object} obj - A collection to iterate over.
* @param {Function} iteratee - A function to apply to each value and key in
diff --git a/lib/mapValuesLimit.js b/lib/mapValuesLimit.js
index 762b871..bced034 100644
--- a/lib/mapValuesLimit.js
+++ b/lib/mapValuesLimit.js
@@ -1,13 +1,14 @@
import eachOfLimit from './eachOfLimit';
/**
- * The same as `mapValues` but runs a maximum of `limit` async operations at a
+ * The same as [`mapValues`]{@link module:Collections.mapValues} but runs a maximum of `limit` async operations at a
* time.
*
* @name mapValuesLimit
* @static
- * @memberOf async
- * @see async.mapValues
+ * @memberOf module:Collections
+ * @method
+ * @see [async.mapValues]{@link module:Collections.mapValues}
* @category Collection
* @param {Object} obj - A collection to iterate over.
* @param {number} limit - The maximum number of async operations at a time.
diff --git a/lib/mapValuesSeries.js b/lib/mapValuesSeries.js
index 163d474..b97fcd1 100644
--- a/lib/mapValuesSeries.js
+++ b/lib/mapValuesSeries.js
@@ -2,12 +2,13 @@ import mapValuesLimit from './mapValuesLimit';
import doLimit from './internal/doLimit';
/**
- * The same as `mapValues` but runs only a single async operation at a time.
+ * The same as [`mapValues`]{@link module:Collections.mapValues} but runs only a single async operation at a time.
*
* @name mapValuesSeries
* @static
- * @memberOf async
- * @see async.mapValues
+ * @memberOf module:Collections
+ * @method
+ * @see [async.mapValues]{@link module:Collections.mapValues}
* @category Collection
* @param {Object} obj - A collection to iterate over.
* @param {Function} iteratee - A function to apply to each value in `obj`.
diff --git a/lib/memoize.js b/lib/memoize.js
index 5b06cff..31c041c 100644
--- a/lib/memoize.js
+++ b/lib/memoize.js
@@ -24,7 +24,8 @@ function has(obj, key) {
*
* @name memoize
* @static
- * @memberOf async
+ * @memberOf module:Utils
+ * @method
* @category Util
* @param {Function} fn - The function to proxy and cache results from.
* @param {Function} hasher - An optional function for generating a custom hash
diff --git a/lib/nextTick.js b/lib/nextTick.js
index 9a1d6a0..62d20de 100644
--- a/lib/nextTick.js
+++ b/lib/nextTick.js
@@ -12,7 +12,8 @@ import { hasNextTick, hasSetImmediate, fallback, wrap } from './internal/setImm
*
* @name nextTick
* @static
- * @memberOf async
+ * @memberOf module:Utils
+ * @method
* @alias setImmediate
* @category Util
* @param {Function} callback - The function to call on a later loop around
diff --git a/lib/parallel.js b/lib/parallel.js
index 5a01b5f..1f6a3cc 100644
--- a/lib/parallel.js
+++ b/lib/parallel.js
@@ -21,7 +21,8 @@ import doLimit from './internal/doLimit';
*
* @name parallel
* @static
- * @memberOf async
+ * @memberOf module:ControlFlow
+ * @method
* @category Control Flow
* @param {Array|Object} tasks - A collection containing functions to run.
* Each function is passed a `callback(err, result)` which it must call on
diff --git a/lib/parallelLimit.js b/lib/parallelLimit.js
index 2eb8b2f..926fa85 100644
--- a/lib/parallelLimit.js
+++ b/lib/parallelLimit.js
@@ -2,13 +2,14 @@ import eachOfLimit from './internal/eachOfLimit';
import parallel from './internal/parallel';
/**
- * The same as `parallel` but runs a maximum of `limit` async operations at a
+ * The same as [`parallel`]{@link module:ControlFlow.parallel} but runs a maximum of `limit` async operations at a
* time.
*
- * @name parallel
+ * @name parallelLimit
* @static
- * @memberOf async
- * @see async.parallel
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.parallel]{@link module:ControlFlow.parallel}
* @category Control Flow
* @param {Array|Collection} tasks - A collection containing functions to run.
* Each function is passed a `callback(err, result)` which it must call on
diff --git a/lib/priorityQueue.js b/lib/priorityQueue.js
index 36cacaf..9ea24bc 100644
--- a/lib/priorityQueue.js
+++ b/lib/priorityQueue.js
@@ -7,13 +7,14 @@ import setImmediate from './setImmediate';
import queue from './queue';
/**
- * The same as {@link async.queue} only tasks are assigned a priority and
+ * The same as [async.queue]{@link module:ControlFlow.queue} only tasks are assigned a priority and
* completed in ascending priority order.
*
* @name priorityQueue
* @static
- * @memberOf async
- * @see async.queue
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.queue]{@link module:ControlFlow.queue}
* @category Control Flow
* @param {Function} worker - An asynchronous function for processing a queued
* task, which must call its `callback(err)` argument when finished, with an
@@ -23,7 +24,7 @@ import queue from './queue';
* @param {number} concurrency - An `integer` for determining how many `worker`
* functions should be run in parallel. If omitted, the concurrency defaults to
* `1`. If the concurrency is `0`, an error is thrown.
- * @returns {queue} A priorityQueue object to manage the tasks. There are two
+ * @returns {module:ControlFlow.QueueObject} A priorityQueue object to manage the tasks. There are two
* differences between `queue` and `priorityQueue` objects:
* * `push(task, priority, [callback])` - `priority` should be a number. If an
* array of `tasks` is given, all tasks will be assigned the same priority.
diff --git a/lib/queue.js b/lib/queue.js
index ac1987a..109ba50 100644
--- a/lib/queue.js
+++ b/lib/queue.js
@@ -2,26 +2,27 @@ import queue from './internal/queue';
/**
* A queue of tasks for the worker function to complete.
- * @typedef {Object} queue
+ * @typedef {Object} QueueObject
+ * @memberOf module:ControlFlow
* @property {Function} length - a function returning the number of items
- * waiting to be processed. Invoke with ().
+ * waiting to be processed. Invoke with `queue.length()`.
* @property {Function} started - a function returning whether or not any
- * items have been pushed and processed by the queue. Invoke with ().
+ * items have been pushed and processed by the queue. Invoke with `queue.started()`.
* @property {Function} running - a function returning the number of items
- * currently being processed. Invoke with ().
+ * currently being processed. Invoke with `queue.running()`.
* @property {Function} workersList - a function returning the array of items
- * currently being processed. Invoke with ().
+ * currently being processed. Invoke with `queue.workersList()`.
* @property {Function} idle - a function returning false if there are items
- * waiting or being processed, or true if not. Invoke with ().
+ * waiting or being processed, or true if not. Invoke with `queue.idle()`.
* @property {number} concurrency - an integer for determining how many `worker`
* functions should be run in parallel. This property can be changed after a
* `queue` is created to alter the concurrency on-the-fly.
* @property {Function} push - add a new task to the `queue`. Calls `callback`
* once the `worker` has finished processing the task. Instead of a single task,
* a `tasks` array can be submitted. The respective callback is used for every
- * task in the list. Invoke with (task, [callback]),
+ * task in the list. Invoke with `queue.push(task, [callback])`,
* @property {Function} unshift - add a new task to the front of the `queue`.
- * Invoke with (task, [callback]).
+ * Invoke with `queue.unshift(task, [callback])`.
* @property {Function} saturated - a callback that is called when the number of
* running workers hits the `concurrency` limit, and further tasks will be
* queued.
@@ -39,11 +40,11 @@ import queue from './internal/queue';
* @property {boolean} paused - a boolean for determining whether the queue is
* in a paused state.
* @property {Function} pause - a function that pauses the processing of tasks
- * until `resume()` is called. Invoke with ().
+ * until `resume()` is called. Invoke with `queue.pause()`.
* @property {Function} resume - a function that resumes the processing of
- * queued tasks when the queue is paused. Invoke with ().
+ * queued tasks when the queue is paused. Invoke with `queue.length()`.
* @property {Function} kill - a function that removes the `drain` callback and
- * empties remaining tasks from the queue forcing it to go idle. Invoke with ().
+ * empties remaining tasks from the queue forcing it to go idle. Invoke with `queue.kill()`.
*/
/**
@@ -54,7 +55,8 @@ import queue from './internal/queue';
*
* @name queue
* @static
- * @memberOf async
+ * @memberOf module:ControlFlow
+ * @method
* @category Control Flow
* @param {Function} worker - An asynchronous function for processing a queued
* task, which must call its `callback(err)` argument when finished, with an
@@ -64,7 +66,7 @@ import queue from './internal/queue';
* @param {number} [concurrency=1] - An `integer` for determining how many
* `worker` functions should be run in parallel. If omitted, the concurrency
* defaults to `1`. If the concurrency is `0`, an error is thrown.
- * @returns {queue} A queue object to manage the tasks. Callbacks can
+ * @returns {module:ControlFlow.QueueObject} A queue object to manage the tasks. Callbacks can
* attached as certain properties to listen for specific events during the
* lifecycle of the queue.
* @example
diff --git a/lib/race.js b/lib/race.js
index 2b8ad39..893e860 100644
--- a/lib/race.js
+++ b/lib/race.js
@@ -11,7 +11,8 @@ import once from './internal/once';
*
* @name race
* @static
- * @memberOf async
+ * @memberOf module:ControlFlow
+ * @method
* @category Control Flow
* @param {Array} tasks - An array containing functions to run. Each function
* is passed a `callback(err, result)` which it must call on completion with an
diff --git a/lib/reduce.js b/lib/reduce.js
index 8f529a0..8145db7 100644
--- a/lib/reduce.js
+++ b/lib/reduce.js
@@ -13,7 +13,8 @@ import eachOfSeries from './eachOfSeries';
*
* @name reduce
* @static
- * @memberOf async
+ * @memberOf module:Collections
+ * @method
* @alias inject
* @alias foldl
* @category Collection
diff --git a/lib/reduceRight.js b/lib/reduceRight.js
index fda0505..69fd158 100644
--- a/lib/reduceRight.js
+++ b/lib/reduceRight.js
@@ -3,12 +3,13 @@ import reduce from './reduce';
var slice = Array.prototype.slice;
/**
- * Same as `reduce`, only operates on `coll` in reverse order.
+ * Same as [`reduce`]{@link module:Collections.reduce}, only operates on `coll` in reverse order.
*
* @name reduceRight
* @static
- * @memberOf async
- * @see async.reduce
+ * @memberOf module:Collections
+ * @method
+ * @see [async.reduce]{@link module:Collections.reduce}
* @alias foldr
* @category Collection
* @param {Array|Object} coll - A collection to iterate over.
diff --git a/lib/reflect.js b/lib/reflect.js
index 63adefb..ac5345d 100644
--- a/lib/reflect.js
+++ b/lib/reflect.js
@@ -9,7 +9,8 @@ import rest from 'lodash/rest';
*
* @name reflect
* @static
- * @memberOf async
+ * @memberOf module:Utils
+ * @method
* @category Util
* @param {Function} fn - The function you want to wrap
* @returns {Function} - A function that always passes null to it's callback as
diff --git a/lib/reflectAll.js b/lib/reflectAll.js
index ac9ea06..a9fe48f 100644
--- a/lib/reflectAll.js
+++ b/lib/reflectAll.js
@@ -5,8 +5,9 @@ import reflect from './reflect';
*
* @name reflectAll
* @static
- * @memberOf async
- * @see async.reflect
+ * @memberOf module:Utils
+ * @method
+ * @see [async.reflect]{@link module:Utils.reflect}
* @category Util
* @param {Array} tasks - The array of functions to wrap in `async.reflect`.
* @returns {Array} Returns an array of functions, each function wrapped in
diff --git a/lib/reject.js b/lib/reject.js
index f4c7a45..f882a93 100644
--- a/lib/reject.js
+++ b/lib/reject.js
@@ -2,12 +2,13 @@ import rejectLimit from './rejectLimit';
import doLimit from './internal/doLimit';
/**
- * The opposite of `filter`. Removes values that pass an `async` truth test.
+ * The opposite of [`filter`]{@link module:Collections.filter}. Removes values that pass an `async` truth test.
*
* @name reject
* @static
- * @memberOf async
- * @see async.filter
+ * @memberOf module:Collections
+ * @method
+ * @see [async.filter]{@link module:Collections.filter}
* @category Collection
* @param {Array|Object} coll - A collection to iterate over.
* @param {Function} iteratee - A truth test to apply to each item in `coll`.
diff --git a/lib/rejectLimit.js b/lib/rejectLimit.js
index a8e2082..2a57bc7 100644
--- a/lib/rejectLimit.js
+++ b/lib/rejectLimit.js
@@ -2,13 +2,14 @@ import reject from './internal/reject';
import doParallelLimit from './internal/doParallelLimit';
/**
- * The same as `reject` but runs a maximum of `limit` async operations at a
+ * The same as [`reject`]{@link module:Collections.reject} but runs a maximum of `limit` async operations at a
* time.
*
* @name rejectLimit
* @static
- * @memberOf async
- * @see async.reject
+ * @memberOf module:Collections
+ * @method
+ * @see [async.reject]{@link module:Collections.reject}
* @category Collection
* @param {Array|Object} coll - A collection to iterate over.
* @param {number} limit - The maximum number of async operations at a time.
diff --git a/lib/rejectSeries.js b/lib/rejectSeries.js
index 8fc7a41..0844864 100644
--- a/lib/rejectSeries.js
+++ b/lib/rejectSeries.js
@@ -2,12 +2,13 @@ import rejectLimit from './rejectLimit';
import doLimit from './internal/doLimit';
/**
- * The same as `reject` but runs only a single async operation at a time.
+ * The same as [`reject`]{@link module:Collections.reject} but runs only a single async operation at a time.
*
* @name rejectSeries
* @static
- * @memberOf async
- * @see async.reject
+ * @memberOf module:Collections
+ * @method
+ * @see [async.reject]{@link module:Collections.reject}
* @category Collection
* @param {Array|Object} coll - A collection to iterate over.
* @param {Function} iteratee - A truth test to apply to each item in `coll`.
diff --git a/lib/retry.js b/lib/retry.js
index 69c3eb3..5c22af3 100644
--- a/lib/retry.js
+++ b/lib/retry.js
@@ -10,7 +10,8 @@ import constant from 'lodash/constant';
*
* @name retry
* @static
- * @memberOf async
+ * @memberOf module:ControlFlow
+ * @method
* @category Control Flow
* @param {Object|number} [opts = {times: 5, interval: 0}| 5] - Can be either an
* object with `times` and `interval` or a number.
diff --git a/lib/retryable.js b/lib/retryable.js
index b9c0fbb..00fd8f2 100644
--- a/lib/retryable.js
+++ b/lib/retryable.js
@@ -2,13 +2,14 @@ import retry from './retry';
import initialParams from './internal/initialParams';
/**
- * A close relative of `retry`. This method wraps a task and makes it
+ * A close relative of [`retry`]{@link module:ControlFlow.retry}. This method wraps a task and makes it
* retryable, rather than immediately calling it with retries.
*
* @name retryable
* @static
- * @memberOf async
- * @see async.retry
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.retry]{@link module:ControlFlow.retry}
* @category Control Flow
* @param {Object|number} [opts = {times: 5, interval: 0}| 5] - optional
* options, exactly the same as from `retry`
diff --git a/lib/seq.js b/lib/seq.js
index 4b3e49c..01355b1 100644
--- a/lib/seq.js
+++ b/lib/seq.js
@@ -5,14 +5,15 @@ import reduce from './reduce';
/**
* 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
- * {@link async.compose} with the arguments reversed.
+ * [compose]{@link module:ControlFlow.compose} with the arguments reversed.
*
* Each function is executed with the `this` binding of the composed function.
*
* @name seq
* @static
- * @memberOf async
- * @see async.compose
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.compose]{@link module:ControlFlow.compose}
* @category Control Flow
* @param {...Function} functions - the asynchronous functions to compose
* @returns {Function} a function that composes the `functions` in order
diff --git a/lib/series.js b/lib/series.js
index 3345519..1969943 100644
--- a/lib/series.js
+++ b/lib/series.js
@@ -24,7 +24,8 @@ import eachOfSeries from './eachOfSeries';
*
* @name series
* @static
- * @memberOf async
+ * @memberOf module:ControlFlow
+ * @method
* @category Control Flow
* @param {Array|Object} tasks - A collection containing functions to run, each
* function is passed a `callback(err, result)` it must call on completion with
diff --git a/lib/setImmediate.js b/lib/setImmediate.js
index 68f94d7..f820b46 100644
--- a/lib/setImmediate.js
+++ b/lib/setImmediate.js
@@ -10,7 +10,8 @@ import setImmediate from './internal/setImmediate';
*
* @name setImmediate
* @static
- * @memberOf async
+ * @memberOf module:Utils
+ * @method
* @alias nextTick
* @category Util
* @param {Function} callback - The function to call on a later loop around
diff --git a/lib/some.js b/lib/some.js
index 4f4e2b1..ff777e5 100644
--- a/lib/some.js
+++ b/lib/some.js
@@ -8,7 +8,8 @@ import doLimit from './internal/doLimit';
*
* @name some
* @static
- * @memberOf async
+ * @memberOf module:Collections
+ * @method
* @alias any
* @category Collection
* @param {Array|Object} coll - A collection to iterate over.
diff --git a/lib/someLimit.js b/lib/someLimit.js
index 50beb65..ad65721 100644
--- a/lib/someLimit.js
+++ b/lib/someLimit.js
@@ -3,12 +3,13 @@ import eachOfLimit from './eachOfLimit';
import identity from 'lodash/identity';
/**
- * The same as `some` but runs a maximum of `limit` async operations at a time.
+ * The same as [`some`]{@link module:Collections.some} but runs a maximum of `limit` async operations at a time.
*
* @name someLimit
* @static
- * @memberOf async
- * @see async.some
+ * @memberOf module:Collections
+ * @method
+ * @see [async.some]{@link module:Collections.some}
* @alias anyLimit
* @category Collection
* @param {Array|Object} coll - A collection to iterate over.
diff --git a/lib/someSeries.js b/lib/someSeries.js
index 18fd5ca..cc30c36 100644
--- a/lib/someSeries.js
+++ b/lib/someSeries.js
@@ -2,12 +2,13 @@ import someLimit from './someLimit';
import doLimit from './internal/doLimit';
/**
- * The same as `some` but runs only a single async operation at a time.
+ * The same as [`some`]{@link module:Collections.some} but runs only a single async operation at a time.
*
* @name someSeries
* @static
- * @memberOf async
- * @see async.some
+ * @memberOf module:Collections
+ * @method
+ * @see [async.some]{@link module:Collections.some}
* @alias anySeries
* @category Collection
* @param {Array|Object} coll - A collection to iterate over.
diff --git a/lib/sortBy.js b/lib/sortBy.js
index 539a829..ab6c420 100644
--- a/lib/sortBy.js
+++ b/lib/sortBy.js
@@ -9,7 +9,8 @@ import map from './map';
*
* @name sortBy
* @static
- * @memberOf async
+ * @memberOf module:Collections
+ * @method
* @category Collection
* @param {Array|Object} coll - A collection to iterate over.
* @param {Function} iteratee - A function to apply to each item in `coll`.
diff --git a/lib/timeout.js b/lib/timeout.js
index 1ce5378..7caba44 100644
--- a/lib/timeout.js
+++ b/lib/timeout.js
@@ -7,7 +7,8 @@ import initialParams from './internal/initialParams';
*
* @name timeout
* @static
- * @memberOf async
+ * @memberOf module:Utils
+ * @method
* @category Util
* @param {Function} asyncFn - The asynchronous function you want to set the
* time limit.
diff --git a/lib/times.js b/lib/times.js
index 1d5b6c3..bdd2e6b 100644
--- a/lib/times.js
+++ b/lib/times.js
@@ -3,17 +3,18 @@ import doLimit from './internal/doLimit';
/**
* Calls the `iteratee` function `n` times, and accumulates results in the same
- * manner you would use with {@link async.map}.
+ * manner you would use with [map]{@link module:Collections.map}.
*
* @name times
* @static
- * @memberOf async
- * @see async.map
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.map]{@link module:Collections.map}
* @category Control Flow
* @param {number} n - The number of times to run the function.
* @param {Function} iteratee - The function to call `n` times. Invoked with the
* iteration index and a callback (n, next).
- * @param {Function} callback - see {@link async.map}.
+ * @param {Function} callback - see {@link module:Collections.map}.
* @example
*
* // Pretend this is some complicated async factory
diff --git a/lib/timesLimit.js b/lib/timesLimit.js
index b4db62c..68d5ede 100644
--- a/lib/timesLimit.js
+++ b/lib/timesLimit.js
@@ -2,19 +2,20 @@ import mapLimit from './mapLimit';
import range from 'lodash/_baseRange';
/**
-* The same as {@link times} but runs a maximum of `limit` async operations at a
-* time.
+ * The same as [times]{@link module:ControlFlow.times} but runs a maximum of `limit` async operations at a
+ * time.
*
* @name timesLimit
* @static
- * @memberOf async
- * @see async.times
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.times]{@link module:ControlFlow.times}
* @category Control Flow
* @param {number} count - The number of times to run the function.
* @param {number} limit - The maximum number of async operations at a time.
* @param {Function} iteratee - The function to call `n` times. Invoked with the
* iteration index and a callback (n, next).
- * @param {Function} callback - see {@link async.map}.
+ * @param {Function} callback - see [async.map]{@link module:Collections.map}.
*/
export default function timeLimit(count, limit, iteratee, callback) {
mapLimit(range(0, count, 1), limit, iteratee, callback);
diff --git a/lib/timesSeries.js b/lib/timesSeries.js
index 28a5434..672428d 100644
--- a/lib/timesSeries.js
+++ b/lib/timesSeries.js
@@ -2,16 +2,17 @@ import timesLimit from './timesLimit';
import doLimit from './internal/doLimit';
/**
- * The same as {@link async.times} but runs only a single async operation at a time.
+ * The same as [times]{@link module:ControlFlow.times} but runs only a single async operation at a time.
*
* @name timesSeries
* @static
- * @memberOf async
- * @see async.times
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.times]{@link module:ControlFlow.times}
* @category Control Flow
* @param {number} n - The number of times to run the function.
* @param {Function} iteratee - The function to call `n` times. Invoked with the
* iteration index and a callback (n, next).
- * @param {Function} callback - see {@link async.map}.
+ * @param {Function} callback - see {@link module:Collections.map}.
*/
export default doLimit(timesLimit, 1);
diff --git a/lib/transform.js b/lib/transform.js
index 55fd067..6098522 100644
--- a/lib/transform.js
+++ b/lib/transform.js
@@ -9,7 +9,8 @@ import eachOf from './eachOf';
*
* @name transform
* @static
- * @memberOf async
+ * @memberOf module:Collections
+ * @method
* @category Collection
* @param {Array|Object} coll - A collection to iterate over.
* @param {*} [accumulator] - The initial state of the transform. If omitted,
diff --git a/lib/unmemoize.js b/lib/unmemoize.js
index e7d9765..4b2db4d 100644
--- a/lib/unmemoize.js
+++ b/lib/unmemoize.js
@@ -1,11 +1,12 @@
/**
- * Undoes a {@link async.memoize}d function, reverting it to the original,
+ * Undoes a [memoize]{@link module:Utils.memoize}d function, reverting it to the original,
* unmemoized form. Handy for testing.
*
* @name unmemoize
* @static
- * @memberOf async
- * @see async.memoize
+ * @memberOf module:Utils
+ * @method
+ * @see [async.memoize]{@link module:Utils.memoize}
* @category Util
* @param {Function} fn - the memoized function
* @returns {Function} a function that calls the original unmemoized function
diff --git a/lib/until.js b/lib/until.js
index 910e049..7b0b0b5 100644
--- a/lib/until.js
+++ b/lib/until.js
@@ -5,12 +5,13 @@ import whilst from './whilst';
* stopped, or an error occurs. `callback` will be passed an error and any
* arguments passed to the final `fn`'s callback.
*
- * The inverse of {@link async.whilst}.
+ * The inverse of [whilst]{@link module:ControlFlow.whilst}.
*
* @name until
* @static
- * @memberOf async
- * @see async.whilst
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.whilst]{@link module:ControlFlow.whilst}
* @category Control Flow
* @param {Function} test - synchronous truth test to perform before each
* execution of `fn`. Invoked with ().
diff --git a/lib/waterfall.js b/lib/waterfall.js
index 9478bd9..b3f0dbc 100644
--- a/lib/waterfall.js
+++ b/lib/waterfall.js
@@ -13,7 +13,8 @@ import onlyOnce from './internal/onlyOnce';
*
* @name waterfall
* @static
- * @memberOf async
+ * @memberOf module:ControlFlow
+ * @method
* @category Control Flow
* @param {Array} tasks - An array of functions to run, each function is passed
* a `callback(err, result1, result2, ...)` it must call on completion. The
diff --git a/lib/whilst.js b/lib/whilst.js
index ee1c19a..3311f4c 100644
--- a/lib/whilst.js
+++ b/lib/whilst.js
@@ -7,7 +7,8 @@ import rest from 'lodash/rest';
*
* @name whilst
* @static
- * @memberOf async
+ * @memberOf module:ControlFlow
+ * @method
* @category Control Flow
* @param {Function} test - synchronous truth test to perform before each
* execution of `fn`. Invoked with ().
diff --git a/package.json b/package.json
index d3429f3..250e062 100644
--- a/package.json
+++ b/package.json
@@ -31,16 +31,19 @@
"benchmark": "bestiejs/benchmark.js",
"bluebird": "^2.9.32",
"chai": "^3.1.0",
+ "cheerio": "^0.20.0",
"coveralls": "^2.11.2",
"es6-promise": "^2.3.0",
+ "esdoc": "^0.4.7",
"eslint": "^2.11.1",
"fs-extra": "^0.26.7",
- "jscs-jsdoc": "^1.3.2",
+ "jsdoc": "^3.4.0",
"karma": "^0.13.2",
"karma-browserify": "^4.2.1",
"karma-firefox-launcher": "^0.1.6",
"karma-mocha": "^0.2.0",
"karma-mocha-reporter": "^1.0.2",
+ "minami": "^1.1.1",
"mocha": "^2.2.5",
"native-promise-only": "^0.8.0-a",
"nyc": "^2.1.0",
@@ -52,11 +55,15 @@
"rsvp": "^3.0.18",
"semver": "^4.3.6",
"uglify-js": "~2.4.0",
+ "vinyl-buffer": "^1.0.0",
+ "vinyl-source-stream": "^1.1.0",
"yargs": "~3.9.1"
},
"scripts": {
"coverage": "nyc npm test && nyc report",
"coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls",
+ "doc": "esdoc -c ./support/esdoc.json",
+ "jsdoc": "jsdoc -c ./support/jsdoc/jsdoc.json && node support/jsdoc/jsdoc-fix-html.js",
"lint": "eslint lib/ mocha_test/ perf/memory.js perf/suites.js perf/benchmark.js support/ karma.conf.js",
"mocha-browser-test": "karma start",
"mocha-node-test": "mocha mocha_test/ --compilers js:babel-core/register",
diff --git a/support/esdoc.json b/support/esdoc.json
new file mode 100644
index 0000000..215d29a
--- /dev/null
+++ b/support/esdoc.json
@@ -0,0 +1,6 @@
+{
+ "source": "./lib",
+ "destination": "./docs",
+ "excludes": ["internal"],
+ "scripts": ["./dist/async.js"]
+}
diff --git a/support/jsdoc/head-data.html b/support/jsdoc/head-data.html
new file mode 100644
index 0000000..c8bd13c
--- /dev/null
+++ b/support/jsdoc/head-data.html
@@ -0,0 +1,10 @@
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+
+<link rel="icon" href="favicon.ico?v=2" />
+<link src="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/bootstrap/3.3.6/css/bootstrap.min.css">
+<link src="text/css" rel="stylesheet" href="styles/jsdoc-custom.css">
+<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 src="scripts/async.js"></script>
diff --git a/support/jsdoc/jsdoc-custom.css b/support/jsdoc/jsdoc-custom.css
new file mode 100644
index 0000000..9cc2d3f
--- /dev/null
+++ b/support/jsdoc/jsdoc-custom.css
@@ -0,0 +1,83 @@
+.page-title {
+ padding-top: 12px;
+}
+
+.navbar-fixed-top {
+ background-color: #101010;
+}
+
+.navbar-fixed-top .navbar-right {
+ padding-right: 10px;
+}
+
+.navbar .ion-social-github {
+ font-size: 1.2em;
+}
+
+body {
+ height: 100%;
+ width: 100%;
+ padding-left: 0px;
+}
+
+body nav {
+ float: none;
+ position: fixed;
+ top: 50px;
+ left: 0px;
+ bottom: 0px;
+ padding-left: 12px;
+ overflow-y: auto;
+}
+
+/* fix bootstrap's styling */
+pre {
+ background: #fff;
+ padding: 0px;
+}
+
+footer {
+ margin-left: 0px;
+}
+
+.navbar-brand {
+ padding: 5px;
+}
+
+.navbar-brand img {
+ height: 40px;
+}
+
+#main {
+ position: fixed;
+ float: none;
+ overflow-y: auto;
+ margin-left: 250px;
+ top: 50px;
+ height: calc(100% - 50px);
+}
+
+.tt-menu {
+ background-color: white;
+ padding: 10px;
+ width: 100%;
+ border-radius: 4px;
+ border: 1px solid #D3D3D3;
+ z-index: 11;
+ overflow-y: auto;
+}
+
+.tt-cursor {
+ background-color: #D3D3D3;
+}
+
+.search-bar-header-first {
+ margin: 5px 0px;
+ border-bottom: 1px solid #D3D3D3;
+}
+
+.search-bar-header {
+ margin: 5px 0px;
+ border-top: 1px solid #D3D3D3;
+ border-bottom: 1px solid #D3D3D3;
+}
diff --git a/support/jsdoc/jsdoc-custom.js b/support/jsdoc/jsdoc-custom.js
new file mode 100644
index 0000000..a53aaf6
--- /dev/null
+++ b/support/jsdoc/jsdoc-custom.js
@@ -0,0 +1,105 @@
+/* eslint no-undef: "off" */
+$(function initSearchBar() {
+ function matchSubstrs(methodName) {
+ var tokens = [];
+ var len = methodName.length;
+ for (var size = 1; size <= len; size++){
+ for (var i = 0; i+size<= len; i++){
+ tokens.push(methodName.substr(i, size));
+ }
+ }
+ return tokens;
+ }
+
+ var methodNames = new Bloodhound({
+ datumTokenizer: matchSubstrs,
+ queryTokenizer: Bloodhound.tokenizers.whitespace,
+ prefetch: {
+ url: './data/methodNames.json',
+ cache: false
+ }
+ });
+
+ var sourceFiles = new Bloodhound({
+ datumTokenizer: matchSubstrs,
+ queryTokenizer: Bloodhound.tokenizers.whitespace,
+ prefetch: {
+ url: './data/sourceFiles.json',
+ cache: false
+ }
+ });
+
+ var githubIssues = new Bloodhound({
+ datumTokenizer: Bloodhound.tokenizers.whitespace,
+ queryTokenizer: Bloodhound.tokenizers.whitespace,
+ remote: {
+ url: 'https://api.github.com/search/issues?q=%QUERY+repo:caolan/async',
+ cache: true,
+ wildcard: '%QUERY',
+ transform: function(response) {
+ return $.map(response.items, function(issue) {
+ // if (issue.state !== 'open') {
+ // return null;
+ // }
+ return {
+ url: issue.html_url,
+ name: issue.number + ': ' + issue.title,
+ number: issue.number
+ };
+ }).sort(function(a, b) {
+ return b.number - a.number;
+ });
+ }
+ }
+ });
+
+ $('.typeahead').typeahead({
+ hint: true,
+ highlight: true,
+ minLength: 1
+ }, {
+ name: 'Methods',
+ source: methodNames,
+ templates: {
+ header: '<h3 class="search-bar-header-first">Methods</h3>'
+ }
+ }, {
+ name: 'Files',
+ source: sourceFiles,
+ templates: {
+ header: '<h3 class="search-bar-header">Source Files</h3>'
+ }
+ }, {
+ name: 'Issues',
+ source: githubIssues,
+ display: 'name',
+ templates: {
+ header: '<h3 class="search-bar-header">Issues</h3>'
+ }
+ }).on('typeahead:select', function(ev, suggestion) {
+ var host;
+ if (location.origin != "null") {
+ host = location.origin;
+ } else {
+ host = location.protocol + '//' + location.host;
+ }
+
+ var _path = location.pathname.split("/");
+ var currentPage = _path[_path.length - 1];
+ host += "/" + _path.slice(1, -1).join("/") + "/";
+
+ // handle issues
+ if (typeof suggestion !== 'string') {
+ location.href = suggestion.url;
+ // handle source files
+ } else if (suggestion.indexOf('.html') !== -1) {
+ location.href = host + suggestion;
+ // handle searching from one of the source files or the home page
+ } else if (currentPage !== 'docs.html') {
+ location.href = host + 'docs.html#.' + suggestion;
+ } else {
+ var $el = document.getElementById('.' + suggestion);
+ $('#main').animate({ scrollTop: $el.offsetTop }, 500);
+ }
+ });
+});
diff --git a/support/jsdoc/jsdoc-fix-html.js b/support/jsdoc/jsdoc-fix-html.js
new file mode 100644
index 0000000..667d869
--- /dev/null
+++ b/support/jsdoc/jsdoc-fix-html.js
@@ -0,0 +1,212 @@
+var async = require('../../dist/async');
+var fs = require('fs-extra');
+var path = require('path');
+
+var $ = require('cheerio');
+var _ = require('lodash');
+
+var docsDir = path.join(__dirname, '../../docs');
+var pageTitle = 'Methods:';
+
+var docFilename = 'docs.html';
+var mainModuleFile = 'module-async.html';
+var mainSectionId = '#main';
+var sectionTitleClass = '.page-title'
+
+var HTMLFileBegin = '<!DOCTYPE html>\n<html lang="en">\n<head>\n';
+var HTMLFileHeadBodyJoin = '</head>\n<body>';
+var HTMLFileEnd = '</body>';
+
+var additionalFooterText = ' Documentation has been modified from the original. ' +
+ ' For more information, please see the <a href="https://github.com/caolan/async">async</a> repository.';
+
+function generateHTMLFile(filename, $page, callback) {
+ // generate an HTML file from a cheerio object
+ var HTMLdata = HTMLFileBegin + $page.find('head').html()
+ + HTMLFileHeadBodyJoin + $page.find('body').html()
+ + HTMLFileEnd;
+
+ fs.writeFile(filename, HTMLdata, callback);
+}
+
+function extractModuleFiles(files) {
+ return _.filter(files, function(file) {
+ return _.startsWith(file, 'module') && file !== mainModuleFile;
+ });
+}
+
+function getSearchableInfo($page, callback) {
+ var $sourceLinks = $page.find('a[href$=".js.html"]');
+ var sourceFiles = $sourceLinks.map(function() {
+ return $(this).attr('href');
+ }).toArray().sort();
+
+ var $methodLinks = $page.find('nav').find('a');
+ var methods = $methodLinks.map(function() {
+ var methodName = $(this).text();
+ return (methodName === 'Home' ? null : methodName);
+ }).toArray().sort();
+
+ fs.mkdirsSync(path.join(docsDir, 'data'));
+ async.parallel([
+ function(fileCallback) {
+ fs.writeJson(path.join(docsDir, 'data/sourceFiles.json'), sourceFiles, fileCallback);
+ },
+ function(fileCallback) {
+ fs.writeJson(path.join(docsDir, 'data/methodNames.json'), methods, fileCallback);
+ }
+ ], callback);
+}
+
+function combineFakeModules(files, callback) {
+ var moduleFiles = extractModuleFiles(files);
+
+ fs.readFile(path.join(docsDir, mainModuleFile), 'utf8', function(err, mainModuleData) {
+ if (err) return callback(err);
+
+ var $mainPage = $(mainModuleData);
+ // each 'module' (category) has a separate page, with all of the
+ // important information in a 'main' div. Combine all of these divs into
+ // one on the actual module page (async)
+ async.eachSeries(moduleFiles, function(file, fileCallback) {
+ fs.readFile(path.join(docsDir, file), 'utf8', function(err, moduleData) {
+ if (err) return fileCallback(err);
+ var $modulePage = $(moduleData);
+ var moduleName = $modulePage.find(sectionTitleClass).text();
+ $modulePage.find(sectionTitleClass).attr('id', moduleName.toLowerCase());
+ $mainPage.find(mainSectionId).append($modulePage.find(mainSectionId).html());
+ return fileCallback();
+ });
+ }, function(err) {
+ if (err) return callback(err);
+
+ getSearchableInfo($mainPage, function(err) {
+ if (err) return callback(err);
+ generateHTMLFile(path.join(docsDir, docFilename), $mainPage, callback);
+ });
+ });
+ });
+}
+
+function applyPreCheerioFixes(data, headLinks) {
+ var closingHeadTag = '</head>'
+
+ var customScript = '<script src="scripts/jsdoc-custom.js"></script>\n';
+ var closingBodyTag = '</body>';
+
+ var rIncorrectCFText = />ControlFlow</g;
+ var fixedCFText = '>Control Flow<';
+
+ var rIncorrectModuleText = />module:(\w+)\.(\w+)</g
+
+ // the heading needs additional padding at the top so it doesn't get cutoff
+ return data.replace(closingHeadTag, headLinks+closingHeadTag)
+ // inject the async library onto each page
+ .replace(closingBodyTag, customScript+closingBodyTag)
+ // for JSDoc to work, the module needs to be labelled 'ControlFlow', while
+ // on the page it should appear as 'Control Flow'
+ .replace(rIncorrectCFText, fixedCFText)
+ // for return types, JSDoc doesn't allow replacing the link text, so it
+ // needs to be done here
+ .replace(rIncorrectModuleText, function(match, moduleName, methodName) {
+ return '>'+methodName+'<';
+ });
+};
+
+function addStaticHeader($file, $headerContent) {
+ var $body = $file.find('body');
+ $body.prepend($headerContent);
+};
+
+function fixToc($page, moduleFiles) {
+ // remove `async` listing from toc
+ $page.find('li').find('a[href="'+mainModuleFile+'"]').parent().remove();
+
+ // change toc title
+ $page.find('nav').children('h3').text(pageTitle);
+ $page.find('nav').children('h2').remove();
+
+ // make everything point to the same 'docs.html' page
+ _.each(moduleFiles, function(filename) {
+ $page.find('[href^="'+filename+'"]').each(function() {
+ var $ele = $(this);
+ var href = $ele.attr('href');
+
+ // category titles should sections title, while everything else
+ // points to the correct listing
+ if (href === filename) {
+ var moduleName = $ele.text().toLowerCase().replace(/\s/g, '');
+ $ele.attr('href', docFilename+'#'+moduleName);
+ } else {
+ $ele.attr('href', href.replace(filename, docFilename));
+ }
+ });
+ });
+}
+
+function fixFooter($page) {
+ // add a note to the footer that the documentation has been modified
+ var $footer = $page.find('footer');
+ $footer.append(additionalFooterText);
+ $page.find('#main').append($footer);
+};
+
+function fixModuleLinks(files, callback) {
+ var moduleFiles = extractModuleFiles(files);
+
+ async.map(['head-data.html', 'navbar.html'], function(filename, fileCallback) {
+ fs.readFile(path.join(__dirname, filename), 'utf8', function(err, data) {
+ if (err) return fileCallback(err);
+ return fileCallback(null, data);
+ });
+ }, function(err, results) {
+ if (err) return callback(err);
+
+ var $headerContent = $(results[1]);
+ async.each(files, function(file, fileCallback) {
+ var filePath = path.join(docsDir, file);
+ fs.readFile(filePath, 'utf8', function(err, fileData) {
+ if (err) return fileCallback(err);
+ var $file = $(applyPreCheerioFixes(fileData, results[0]));
+
+ addStaticHeader($file, $headerContent);
+ fixToc($file, moduleFiles);
+ fixFooter($file);
+ $file.find('[href="'+mainModuleFile+'"]').attr('href', docFilename);
+ generateHTMLFile(filePath, $file, fileCallback);
+ });
+ }, callback);
+ });
+}
+
+fs.copySync(path.join(__dirname, '../../dist/async.js'), path.join(docsDir, 'scripts/async.js'), { clobber: true });
+fs.copySync(path.join(__dirname, './jsdoc-custom.js'), path.join(docsDir, 'scripts/jsdoc-custom.js'), { clobber: true });
+fs.copySync(path.join(__dirname, './jsdoc-custom.css'), path.join(docsDir, 'styles/jsdoc-custom.css'), { clobber: true });
+fs.copySync(path.join(__dirname, '..', '..', 'logo', 'favicon.ico'), path.join(docsDir, 'favicon.ico'), { clobber: true });
+fs.copySync(path.join(__dirname, '..', '..', 'logo', 'async-logo.svg'), path.join(docsDir, 'img', 'async-logo.svg'), { clobber: true });
+
+fs.readdir(docsDir, function(err, files) {
+ if (err) {
+ throw err;
+ }
+
+ var HTMLFiles = _.filter(files, function(file) {
+ return path.extname(file) === '.html';
+ });
+
+ async.waterfall([
+ function(callback) {
+ combineFakeModules(HTMLFiles, function(err) {
+ if (err) return callback(err);
+ HTMLFiles.push(docFilename);
+ return callback(null);
+ });
+ },
+ function(callback) {
+ fixModuleLinks(HTMLFiles, callback);
+ }
+ ], function(err) {
+ if (err) throw err;
+ console.log('Docs generated successfully');
+ });
+});
diff --git a/support/jsdoc/jsdoc-import-path-plugin.js b/support/jsdoc/jsdoc-import-path-plugin.js
new file mode 100644
index 0000000..3f0937f
--- /dev/null
+++ b/support/jsdoc/jsdoc-import-path-plugin.js
@@ -0,0 +1,21 @@
+const path = require('path');
+
+exports.handlers = {
+ jsdocCommentFound: function(e) {
+ var moduleName = path.parse(e.filename).name;
+
+
+ var lines = e.comment.split(/\r?\n/);
+
+ var importLines = [
+ '```',
+ `import ${moduleName} from 'async/${moduleName}';`,
+ '```'
+ ];
+
+ if (moduleName !== 'index') {
+ e.comment = [lines[0], ...importLines, ...lines.slice(1)].join("\n");
+ }
+
+ }
+};
diff --git a/support/jsdoc/jsdoc.json b/support/jsdoc/jsdoc.json
new file mode 100644
index 0000000..a0e0daa
--- /dev/null
+++ b/support/jsdoc/jsdoc.json
@@ -0,0 +1,20 @@
+{
+ "tags": {
+ "allowUnknownTags": true,
+ "dictionaries": ["jsdoc"]
+ },
+ "source": {
+ "include": [ "./lib" ]
+ },
+ "plugins": ["plugins/markdown", "./jsdoc-import-path-plugin"],
+ "opts": {
+ "readme": "README.md",
+ "template": "node_modules/minami",
+ "encoding": "utf8",
+ "destination": "./docs",
+ "recurse": true
+ },
+ "templates": {
+ "cleverLinks": false
+ }
+}
diff --git a/support/jsdoc/navbar.html b/support/jsdoc/navbar.html
new file mode 100644
index 0000000..86e2792
--- /dev/null
+++ b/support/jsdoc/navbar.html
@@ -0,0 +1,30 @@
+<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"></img>
+ </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">v2.0.0 <span class="caret"></span>
+ </a>
+ <ul class="dropdown-menu">
+ <li><a href="docs.html">v2.0.x</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"><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">
+ </div>
+ </form>
+ </ul>
+</div>