'use strict';12Object.defineProperty(exports, "__esModule", {3value: true4});56var _wrapAsync = require('./internal/wrapAsync.js');78var _wrapAsync2 = _interopRequireDefault(_wrapAsync);910var _mapLimit = require('./mapLimit.js');1112var _mapLimit2 = _interopRequireDefault(_mapLimit);1314var _awaitify = require('./internal/awaitify.js');1516var _awaitify2 = _interopRequireDefault(_awaitify);1718function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }1920/**21* The same as [`concat`]{@link module:Collections.concat} but runs a maximum of `limit` async operations at a time.22*23* @name concatLimit24* @static25* @memberOf module:Collections26* @method27* @see [async.concat]{@link module:Collections.concat}28* @category Collection29* @alias flatMapLimit30* @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.31* @param {number} limit - The maximum number of async operations at a time.32* @param {AsyncFunction} iteratee - A function to apply to each item in `coll`,33* which should use an array as its result. Invoked with (item, callback).34* @param {Function} [callback] - A callback which is called after all the35* `iteratee` functions have finished, or an error occurs. Results is an array36* containing the concatenated results of the `iteratee` function. Invoked with37* (err, results).38* @returns A Promise, if no callback is passed39*/40function concatLimit(coll, limit, iteratee, callback) {41var _iteratee = (0, _wrapAsync2.default)(iteratee);42return (0, _mapLimit2.default)(coll, limit, (val, iterCb) => {43_iteratee(val, (err, ...args) => {44if (err) return iterCb(err);45return iterCb(err, args);46});47}, (err, mapResults) => {48var result = [];49for (var i = 0; i < mapResults.length; i++) {50if (mapResults[i]) {51result = result.concat(...mapResults[i]);52}53}5455return callback(err, result);56});57}58exports.default = (0, _awaitify2.default)(concatLimit, 4);59module.exports = exports['default'];6061