flatMap.js
 1  'use strict';
 2  
 3  Object.defineProperty(exports, "__esModule", {
 4    value: true
 5  });
 6  
 7  var _concatLimit = require('./concatLimit');
 8  
 9  var _concatLimit2 = _interopRequireDefault(_concatLimit);
10  
11  var _awaitify = require('./internal/awaitify');
12  
13  var _awaitify2 = _interopRequireDefault(_awaitify);
14  
15  function _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   */
43  function concat(coll, iteratee, callback) {
44    return (0, _concatLimit2.default)(coll, Infinity, iteratee, callback);
45  }
46  exports.default = (0, _awaitify2.default)(concat, 3);
47  module.exports = exports['default'];