UNPKG

1.74 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6
7var _concatLimit = require('./concatLimit');
8
9var _concatLimit2 = _interopRequireDefault(_concatLimit);
10
11var _awaitify = require('./internal/awaitify');
12
13var _awaitify2 = _interopRequireDefault(_awaitify);
14
15function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
17/**
18 * Applies `iteratee` to each item in `coll`, concatenating the results. Returns
19 * the concatenated list. The `iteratee`s are called in parallel, and the
20 * results are concatenated as they return. The results array will be returned in
21 * the original order of `coll` passed to the `iteratee` function.
22 *
23 * @name concat
24 * @static
25 * @memberOf module:Collections
26 * @method
27 * @category Collection
28 * @alias flatMap
29 * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
30 * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`,
31 * which should use an array as its result. Invoked with (item, callback).
32 * @param {Function} [callback] - A callback which is called after all the
33 * `iteratee` functions have finished, or an error occurs. Results is an array
34 * containing the concatenated results of the `iteratee` function. Invoked with
35 * (err, results).
36 * @returns A Promise, if no callback is passed
37 * @example
38 *
39 * async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files) {
40 * // files is now a list of filenames that exist in the 3 directories
41 * });
42 */
43function concat(coll, iteratee, callback) {
44 return (0, _concatLimit2.default)(coll, Infinity, iteratee, callback);
45}
46exports.default = (0, _awaitify2.default)(concat, 3);
47module.exports = exports['default'];
\No newline at end of file