Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

timesLimit.js 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. var _wrapAsync = require('./internal/wrapAsync');
  11. var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
  12. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  13. /**
  14. * The same as [times]{@link module:ControlFlow.times} but runs a maximum of `limit` async operations at a
  15. * time.
  16. *
  17. * @name timesLimit
  18. * @static
  19. * @memberOf module:ControlFlow
  20. * @method
  21. * @see [async.times]{@link module:ControlFlow.times}
  22. * @category Control Flow
  23. * @param {number} count - The number of times to run the function.
  24. * @param {number} limit - The maximum number of async operations at a time.
  25. * @param {AsyncFunction} iteratee - The async function to call `n` times.
  26. * Invoked with the iteration index and a callback: (n, next).
  27. * @param {Function} callback - see [async.map]{@link module:Collections.map}.
  28. */
  29. function timeLimit(count, limit, iteratee, callback) {
  30. var _iteratee = (0, _wrapAsync2.default)(iteratee);
  31. (0, _mapLimit2.default)((0, _baseRange2.default)(0, count, 1), limit, _iteratee, callback);
  32. }
  33. module.exports = exports['default'];