diff options
author | Hubert Argasinski <argasinski.hubert@gmail.com> | 2016-04-08 01:34:11 -0700 |
---|---|---|
committer | Graeme Yeates <yeatesgraeme@gmail.com> | 2016-04-12 18:46:28 -0400 |
commit | d9675a9032ed86048620a83d3e6bc636fef370b2 (patch) | |
tree | 7376c78560e44f0a057debba12f622cd2284a280 /lib/reflectAll.js | |
parent | 8114c90883857d8390add28976f36d0b9bac31ca (diff) | |
download | async-d9675a9032ed86048620a83d3e6bc636fef370b2.tar.gz |
jsdoc-style documentation finished documenting `Util` methods
need to rebase to master before I can document the recently added
reflect functions
jsdoc-style documentation finished for 'Util' methods
documented the new `reflect` and `reflectAll` functions
Diffstat (limited to 'lib/reflectAll.js')
-rw-r--r-- | lib/reflectAll.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/reflectAll.js b/lib/reflectAll.js index c4ecd9f..2a0f197 100644 --- a/lib/reflectAll.js +++ b/lib/reflectAll.js @@ -2,6 +2,45 @@ import reflect from './reflect'; +/** + * A helper function that wraps an array of functions with reflect. + * + * @name reflectAll + * @static + * @memberOf async + * @see `async.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 + * `async.reflect` + * @example + * + * 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' + * }); + */ export default function reflectAll(tasks) { return tasks.map(reflect); } |