allLimit.js
 1  'use strict';
 2  
 3  Object.defineProperty(exports, "__esModule", {
 4    value: true
 5  });
 6  
 7  var _createTester = require('./internal/createTester');
 8  
 9  var _createTester2 = _interopRequireDefault(_createTester);
10  
11  var _eachOfLimit = require('./internal/eachOfLimit');
12  
13  var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
14  
15  var _awaitify = require('./internal/awaitify');
16  
17  var _awaitify2 = _interopRequireDefault(_awaitify);
18  
19  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20  
21  /**
22   * The same as [`every`]{@link module:Collections.every} but runs a maximum of `limit` async operations at a time.
23   *
24   * @name everyLimit
25   * @static
26   * @memberOf module:Collections
27   * @method
28   * @see [async.every]{@link module:Collections.every}
29   * @alias allLimit
30   * @category Collection
31   * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
32   * @param {number} limit - The maximum number of async operations at a time.
33   * @param {AsyncFunction} iteratee - An async truth test to apply to each item
34   * in the collection in parallel.
35   * The iteratee must complete with a boolean result value.
36   * Invoked with (item, callback).
37   * @param {Function} [callback] - A callback which is called after all the
38   * `iteratee` functions have finished. Result will be either `true` or `false`
39   * depending on the values of the async tests. Invoked with (err, result).
40   * @returns {Promise} a promise, if no callback provided
41   */
42  function everyLimit(coll, limit, iteratee, callback) {
43    return (0, _createTester2.default)(bool => !bool, res => !res)((0, _eachOfLimit2.default)(limit), coll, iteratee, callback);
44  }
45  exports.default = (0, _awaitify2.default)(everyLimit, 4);
46  module.exports = exports['default'];