forEachOfSeries.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _eachOfLimit = require('./eachOfLimit.js');
  6. var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
  7. var _awaitify = require('./internal/awaitify.js');
  8. var _awaitify2 = _interopRequireDefault(_awaitify);
  9. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10. /**
  11. * The same as [`eachOf`]{@link module:Collections.eachOf} but runs only a single async operation at a time.
  12. *
  13. * @name eachOfSeries
  14. * @static
  15. * @memberOf module:Collections
  16. * @method
  17. * @see [async.eachOf]{@link module:Collections.eachOf}
  18. * @alias forEachOfSeries
  19. * @category Collection
  20. * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
  21. * @param {AsyncFunction} iteratee - An async function to apply to each item in
  22. * `coll`.
  23. * Invoked with (item, key, callback).
  24. * @param {Function} [callback] - A callback which is called when all `iteratee`
  25. * functions have finished, or an error occurs. Invoked with (err).
  26. * @returns {Promise} a promise, if a callback is omitted
  27. */
  28. function eachOfSeries(coll, iteratee, callback) {
  29. return (0, _eachOfLimit2.default)(coll, 1, iteratee, callback);
  30. }
  31. exports.default = (0, _awaitify2.default)(eachOfSeries, 3);
  32. module.exports = exports['default'];