source: trip-planner-front/node_modules/async/concatLimit.js@ 6c1585f

Last change on this file since 6c1585f was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.1 KB
Line 
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6
7exports.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
27var _noop = require('lodash/noop');
28
29var _noop2 = _interopRequireDefault(_noop);
30
31var _wrapAsync = require('./internal/wrapAsync');
32
33var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
34
35var _slice = require('./internal/slice');
36
37var _slice2 = _interopRequireDefault(_slice);
38
39var _mapLimit = require('./mapLimit');
40
41var _mapLimit2 = _interopRequireDefault(_mapLimit);
42
43function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
44
45var _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 */
65module.exports = exports['default'];
Note: See TracBrowser for help on using the repository browser.