eachOfLimit.js

  1. import _eachOfLimit from './internal/eachOfLimit';
  2. import wrapAsync from './internal/wrapAsync';
  3. /**
  4. * The same as [`eachOf`]{@link module:Collections.eachOf} but runs a maximum of `limit` async operations at a
  5. * time.
  6. *
  7. * @name eachOfLimit
  8. * @static
  9. * @memberOf module:Collections
  10. * @method
  11. * @see [async.eachOf]{@link module:Collections.eachOf}
  12. * @alias forEachOfLimit
  13. * @category Collection
  14. * @param {Array|Iterable|Object} coll - A collection to iterate over.
  15. * @param {number} limit - The maximum number of async operations at a time.
  16. * @param {AsyncFunction} iteratee - An async function to apply to each
  17. * item in `coll`. The `key` is the item's key, or index in the case of an
  18. * array.
  19. * Invoked with (item, key, callback).
  20. * @param {Function} [callback] - A callback which is called when all
  21. * `iteratee` functions have finished, or an error occurs. Invoked with (err).
  22. */
  23. export default function eachOfLimit(coll, limit, iteratee, callback) {
  24. _eachOfLimit(limit)(coll, wrapAsync(iteratee), callback);
  25. }