timesLimit.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = timeLimit;
  6. var _mapLimit = require('./mapLimit');
  7. var _mapLimit2 = _interopRequireDefault(_mapLimit);
  8. var _baseRange = require('lodash/_baseRange');
  9. var _baseRange2 = _interopRequireDefault(_baseRange);
  10. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11. /**
  12. * The same as [times]{@link module:ControlFlow.times} but runs a maximum of `limit` async operations at a
  13. * time.
  14. *
  15. * @name timesLimit
  16. * @static
  17. * @memberOf module:ControlFlow
  18. * @method
  19. * @see [async.times]{@link module:ControlFlow.times}
  20. * @category Control Flow
  21. * @param {number} count - The number of times to run the function.
  22. * @param {number} limit - The maximum number of async operations at a time.
  23. * @param {Function} iteratee - The function to call `n` times. Invoked with the
  24. * iteration index and a callback (n, next).
  25. * @param {Function} callback - see [async.map]{@link module:Collections.map}.
  26. */
  27. function timeLimit(count, limit, iteratee, callback) {
  28. (0, _mapLimit2.default)((0, _baseRange2.default)(0, count, 1), limit, iteratee, callback);
  29. }
  30. module.exports = exports['default'];