Urara-Blog/node_modules/.pnpm-store/v3/files/ee/0e87c78b7238775852ef1edac068ee637bcd96a5a3fb62be6192d59965919fe9d6439944e29e4ba649067dd29f261948ba2744824c6e203616070ff68dddc1
2022-08-14 01:14:53 +08:00

43 lines
No EOL
1.4 KiB
Text

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = timesLimit;
var _mapLimit = require('./mapLimit.js');
var _mapLimit2 = _interopRequireDefault(_mapLimit);
var _range = require('./internal/range.js');
var _range2 = _interopRequireDefault(_range);
var _wrapAsync = require('./internal/wrapAsync.js');
var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* The same as [times]{@link module:ControlFlow.times} but runs a maximum of `limit` async operations at a
* time.
*
* @name timesLimit
* @static
* @memberOf module:ControlFlow
* @method
* @see [async.times]{@link module:ControlFlow.times}
* @category Control Flow
* @param {number} count - The number of times to run the function.
* @param {number} limit - The maximum number of async operations at a time.
* @param {AsyncFunction} iteratee - The async function to call `n` times.
* Invoked with the iteration index and a callback: (n, next).
* @param {Function} callback - see [async.map]{@link module:Collections.map}.
* @returns {Promise} a promise, if no callback is provided
*/
function timesLimit(count, limit, iteratee, callback) {
var _iteratee = (0, _wrapAsync2.default)(iteratee);
return (0, _mapLimit2.default)((0, _range2.default)(count), limit, _iteratee, callback);
}
module.exports = exports['default'];