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