UNPKG

1.99 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6
7var _applyEach = require('./internal/applyEach.js');
8
9var _applyEach2 = _interopRequireDefault(_applyEach);
10
11var _map = require('./map.js');
12
13var _map2 = _interopRequireDefault(_map);
14
15function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
17/**
18 * Applies the provided arguments to each function in the array, calling
19 * `callback` after all functions have completed. If you only provide the first
20 * argument, `fns`, then it will return a function which lets you pass in the
21 * arguments as if it were a single function call. If more arguments are
22 * provided, `callback` is required while `args` is still optional. The results
23 * for each of the applied async functions are passed to the final callback
24 * as an array.
25 *
26 * @name applyEach
27 * @static
28 * @memberOf module:ControlFlow
29 * @method
30 * @category Control Flow
31 * @param {Array|Iterable|AsyncIterable|Object} fns - A collection of {@link AsyncFunction}s
32 * to all call with the same arguments
33 * @param {...*} [args] - any number of separate arguments to pass to the
34 * function.
35 * @param {Function} [callback] - the final argument should be the callback,
36 * called when all functions have completed processing.
37 * @returns {AsyncFunction} - Returns a function that takes no args other than
38 * an optional callback, that is the result of applying the `args` to each
39 * of the functions.
40 * @example
41 *
42 * const appliedFn = async.applyEach([enableSearch, updateSchema], 'bucket')
43 *
44 * appliedFn((err, results) => {
45 * // results[0] is the results for `enableSearch`
46 * // results[1] is the results for `updateSchema`
47 * });
48 *
49 * // partial application example:
50 * async.each(
51 * buckets,
52 * async (bucket) => async.applyEach([enableSearch, updateSchema], bucket)(),
53 * callback
54 * );
55 */
56exports.default = (0, _applyEach2.default)(_map2.default);
57module.exports = exports.default;
\No newline at end of file