anyLimit.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _createTester = require('./internal/createTester');
  6. var _createTester2 = _interopRequireDefault(_createTester);
  7. var _doParallelLimit = require('./internal/doParallelLimit');
  8. var _doParallelLimit2 = _interopRequireDefault(_doParallelLimit);
  9. var _identity = require('lodash/identity');
  10. var _identity2 = _interopRequireDefault(_identity);
  11. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  12. /**
  13. * The same as [`some`]{@link module:Collections.some} but runs a maximum of `limit` async operations at a time.
  14. *
  15. * @name someLimit
  16. * @static
  17. * @memberOf module:Collections
  18. * @method
  19. * @see [async.some]{@link module:Collections.some}
  20. * @alias anyLimit
  21. * @category Collection
  22. * @param {Array|Iterable|Object} coll - A collection to iterate over.
  23. * @param {number} limit - The maximum number of async operations at a time.
  24. * @param {AsyncFunction} iteratee - An async truth test to apply to each item
  25. * in the collections in parallel.
  26. * The iteratee should complete with a boolean `result` value.
  27. * Invoked with (item, callback).
  28. * @param {Function} [callback] - A callback which is called as soon as any
  29. * iteratee returns `true`, or after all the iteratee functions have finished.
  30. * Result will be either `true` or `false` depending on the values of the async
  31. * tests. Invoked with (err, result).
  32. */
  33. exports.default = (0, _doParallelLimit2.default)((0, _createTester2.default)(Boolean, _identity2.default));
  34. module.exports = exports['default'];