UNPKG

1.63 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6
7var _eachOfLimit2 = require('./internal/eachOfLimit');
8
9var _eachOfLimit3 = _interopRequireDefault(_eachOfLimit2);
10
11var _wrapAsync = require('./internal/wrapAsync');
12
13var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
14
15var _awaitify = require('./internal/awaitify');
16
17var _awaitify2 = _interopRequireDefault(_awaitify);
18
19function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
21/**
22 * The same as [`eachOf`]{@link module:Collections.eachOf} but runs a maximum of `limit` async operations at a
23 * time.
24 *
25 * @name eachOfLimit
26 * @static
27 * @memberOf module:Collections
28 * @method
29 * @see [async.eachOf]{@link module:Collections.eachOf}
30 * @alias forEachOfLimit
31 * @category Collection
32 * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
33 * @param {number} limit - The maximum number of async operations at a time.
34 * @param {AsyncFunction} iteratee - An async function to apply to each
35 * item in `coll`. The `key` is the item's key, or index in the case of an
36 * array.
37 * Invoked with (item, key, callback).
38 * @param {Function} [callback] - A callback which is called when all
39 * `iteratee` functions have finished, or an error occurs. Invoked with (err).
40 * @returns {Promise} a promise, if a callback is omitted
41 */
42function eachOfLimit(coll, limit, iteratee, callback) {
43 return (0, _eachOfLimit3.default)(limit)(coll, (0, _wrapAsync2.default)(iteratee), callback);
44}
45
46exports.default = (0, _awaitify2.default)(eachOfLimit, 4);
47module.exports = exports['default'];
\No newline at end of file