CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes45downloads
someLimit.js47 linesDownload Raw Back to async
1'use strict';2 3Object.defineProperty(exports, "__esModule", {4    value: true5});6 7var _createTester = require('./internal/createTester.js');8 9var _createTester2 = _interopRequireDefault(_createTester);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 [`some`]{@link module:Collections.some} but runs a maximum of `limit` async operations at a time.23 *24 * @name someLimit25 * @static26 * @memberOf module:Collections27 * @method28 * @see [async.some]{@link module:Collections.some}29 * @alias anyLimit30 * @category Collection31 * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.32 * @param {number} limit - The maximum number of async operations at a time.33 * @param {AsyncFunction} iteratee - An async truth test to apply to each item34 * in the collections in parallel.35 * The iteratee should complete with a boolean `result` value.36 * Invoked with (item, callback).37 * @param {Function} [callback] - A callback which is called as soon as any38 * iteratee returns `true`, or after all the iteratee functions have finished.39 * Result will be either `true` or `false` depending on the values of the async40 * tests. Invoked with (err, result).41 * @returns {Promise} a promise, if no callback provided42 */43function someLimit(coll, limit, iteratee, callback) {44    return (0, _createTester2.default)(Boolean, res => res)((0, _eachOfLimit2.default)(limit), coll, iteratee, callback);45}46exports.default = (0, _awaitify2.default)(someLimit, 4);47module.exports = exports.default;
basant307/AI_Governance_Project · CoolFace