1'use strict'; 2 3Object.defineProperty(exports, "__esModule", { 4 value: true 5}); 6 7var _map2 = require('./internal/map.js'); 8 9var _map3 = _interopRequireDefault(_map2); 10 11var _eachOfLimit = require('./internal/eachOfLimit.js'); 12 13var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit); 14 15var _awaitify = require('./internal/awaitify.js'); 16 17var _awaitify2 = _interopRequireDefault(_awaitify); 18 19function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 20 21/** 22 * The same as [`map`]{@link module:Collections.map} but runs a maximum of `limit` async operations at a time. 23 * 24 * @name mapLimit 25 * @static 26 * @memberOf module:Collections 27 * @method 28 * @see [async.map]{@link module:Collections.map} 29 * @category Collection 30 * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. 31 * @param {number} limit - The maximum number of async operations at a time. 32 * @param {AsyncFunction} iteratee - An async function to apply to each item in 33 * `coll`. 34 * The iteratee should complete with the transformed item. 35 * Invoked with (item, callback). 36 * @param {Function} [callback] - A callback which is called when all `iteratee` 37 * functions have finished, or an error occurs. Results is an array of the 38 * transformed items from the `coll`. Invoked with (err, results). 39 * @returns {Promise} a promise, if no callback is passed 40 */ 41function mapLimit(coll, limit, iteratee, callback) { 42 return (0, _map3.default)((0, _eachOfLimit2.default)(limit), coll, iteratee, callback); 43} 44exports.default = (0, _awaitify2.default)(mapLimit, 4); 45module.exports = exports['default'];