1 | 'use strict';
|
---|
2 |
|
---|
3 | Object.defineProperty(exports, "__esModule", {
|
---|
4 | value: true
|
---|
5 | });
|
---|
6 |
|
---|
7 | exports.default = function (coll, limit, iteratee, callback) {
|
---|
8 | callback = callback || _noop2.default;
|
---|
9 | var _iteratee = (0, _wrapAsync2.default)(iteratee);
|
---|
10 | (0, _mapLimit2.default)(coll, limit, function (val, callback) {
|
---|
11 | _iteratee(val, function (err /*, ...args*/) {
|
---|
12 | if (err) return callback(err);
|
---|
13 | return callback(null, (0, _slice2.default)(arguments, 1));
|
---|
14 | });
|
---|
15 | }, function (err, mapResults) {
|
---|
16 | var result = [];
|
---|
17 | for (var i = 0; i < mapResults.length; i++) {
|
---|
18 | if (mapResults[i]) {
|
---|
19 | result = _concat.apply(result, mapResults[i]);
|
---|
20 | }
|
---|
21 | }
|
---|
22 |
|
---|
23 | return callback(err, result);
|
---|
24 | });
|
---|
25 | };
|
---|
26 |
|
---|
27 | var _noop = require('lodash/noop');
|
---|
28 |
|
---|
29 | var _noop2 = _interopRequireDefault(_noop);
|
---|
30 |
|
---|
31 | var _wrapAsync = require('./internal/wrapAsync');
|
---|
32 |
|
---|
33 | var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
|
---|
34 |
|
---|
35 | var _slice = require('./internal/slice');
|
---|
36 |
|
---|
37 | var _slice2 = _interopRequireDefault(_slice);
|
---|
38 |
|
---|
39 | var _mapLimit = require('./mapLimit');
|
---|
40 |
|
---|
41 | var _mapLimit2 = _interopRequireDefault(_mapLimit);
|
---|
42 |
|
---|
43 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
---|
44 |
|
---|
45 | var _concat = Array.prototype.concat;
|
---|
46 |
|
---|
47 | /**
|
---|
48 | * The same as [`concat`]{@link module:Collections.concat} but runs a maximum of `limit` async operations at a time.
|
---|
49 | *
|
---|
50 | * @name concatLimit
|
---|
51 | * @static
|
---|
52 | * @memberOf module:Collections
|
---|
53 | * @method
|
---|
54 | * @see [async.concat]{@link module:Collections.concat}
|
---|
55 | * @category Collection
|
---|
56 | * @param {Array|Iterable|Object} coll - A collection to iterate over.
|
---|
57 | * @param {number} limit - The maximum number of async operations at a time.
|
---|
58 | * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`,
|
---|
59 | * which should use an array as its result. Invoked with (item, callback).
|
---|
60 | * @param {Function} [callback] - A callback which is called after all the
|
---|
61 | * `iteratee` functions have finished, or an error occurs. Results is an array
|
---|
62 | * containing the concatenated results of the `iteratee` function. Invoked with
|
---|
63 | * (err, results).
|
---|
64 | */
|
---|
65 | module.exports = exports['default']; |
---|