eachOfLimit.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = eachOfLimit;
  6. var _eachOfLimit2 = require('./internal/eachOfLimit');
  7. var _eachOfLimit3 = _interopRequireDefault(_eachOfLimit2);
  8. var _wrapAsync = require('./internal/wrapAsync');
  9. var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
  10. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11. /**
  12. * The same as [`eachOf`]{@link module:Collections.eachOf} but runs a maximum of `limit` async operations at a
  13. * time.
  14. *
  15. * @name eachOfLimit
  16. * @static
  17. * @memberOf module:Collections
  18. * @method
  19. * @see [async.eachOf]{@link module:Collections.eachOf}
  20. * @alias forEachOfLimit
  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 function to apply to each
  25. * item in `coll`. The `key` is the item's key, or index in the case of an
  26. * array.
  27. * Invoked with (item, key, callback).
  28. * @param {Function} [callback] - A callback which is called when all
  29. * `iteratee` functions have finished, or an error occurs. Invoked with (err).
  30. */
  31. function eachOfLimit(coll, limit, iteratee, callback) {
  32. (0, _eachOfLimit3.default)(limit)(coll, (0, _wrapAsync2.default)(iteratee), callback);
  33. }
  34. module.exports = exports['default'];