diff --git a/lib/applyEach.js b/lib/applyEach.js index a03dd71a1..e1ec8be5b 100644 --- a/lib/applyEach.js +++ b/lib/applyEach.js @@ -2,13 +2,10 @@ import applyEach from './internal/applyEach.js' import map from './map.js' /** - * Applies the provided arguments to each function in the array, calling - * `callback` after all functions have completed. If you only provide the first - * argument, `fns`, then it will return a function which lets you pass in the - * arguments as if it were a single function call. If more arguments are - * provided, `callback` is required while `args` is still optional. The results - * for each of the applied async functions are passed to the final callback - * as an array. + * Returns a function that applies the provided arguments to each function in + * `fns`. Pass a callback to the returned function to receive the results as an + * array after all functions have completed. Calling the returned function + * without a callback returns a Promise for the results. * * @name applyEach * @static @@ -19,11 +16,8 @@ import map from './map.js' * to all call with the same arguments * @param {...*} [args] - any number of separate arguments to pass to the * function. - * @param {Function} [callback] - the final argument should be the callback, - * called when all functions have completed processing. * @returns {AsyncFunction} - Returns a function that takes no args other than - * an optional callback, that is the result of applying the `args` to each - * of the functions. + * an optional callback. If no callback is passed, it returns a Promise. * @example * * const appliedFn = async.applyEach([enableSearch, updateSchema], 'bucket') @@ -33,7 +27,12 @@ import map from './map.js' * // results[1] is the results for `updateSchema` * }); * - * // partial application example: + * // or use a Promise: + * appliedFn().then(results => { + * console.log(results); + * }); + * + * // apply the same functions to each bucket: * async.each( * buckets, * async (bucket) => async.applyEach([enableSearch, updateSchema], bucket)(), diff --git a/lib/applyEachSeries.js b/lib/applyEachSeries.js index 9dec9ece2..34c23c2cd 100644 --- a/lib/applyEachSeries.js +++ b/lib/applyEachSeries.js @@ -14,10 +14,8 @@ import mapSeries from './mapSeries.js' * call with the same arguments * @param {...*} [args] - any number of separate arguments to pass to the * function. - * @param {Function} [callback] - the final argument should be the callback, - * called when all functions have completed processing. * @returns {AsyncFunction} - A function, that when called, is the result of - * appling the `args` to the list of functions. It takes no args, other than - * a callback. + * applying the `args` to the list of functions. It takes no args, other than + * an optional callback. If no callback is passed, it returns a Promise. */ export default applyEach(mapSeries);