CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
times.js50 linesDownload Raw Back to async
1'use strict';2 3Object.defineProperty(exports, "__esModule", {4    value: true5});6exports.default = times;7 8var _timesLimit = require('./timesLimit.js');9 10var _timesLimit2 = _interopRequireDefault(_timesLimit);11 12function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }13 14/**15 * Calls the `iteratee` function `n` times, and accumulates results in the same16 * manner you would use with [map]{@link module:Collections.map}.17 *18 * @name times19 * @static20 * @memberOf module:ControlFlow21 * @method22 * @see [async.map]{@link module:Collections.map}23 * @category Control Flow24 * @param {number} n - The number of times to run the function.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 {@link module:Collections.map}.28 * @returns {Promise} a promise, if no callback is provided29 * @example30 *31 * // Pretend this is some complicated async factory32 * var createUser = function(id, callback) {33 *     callback(null, {34 *         id: 'user' + id35 *     });36 * };37 *38 * // generate 5 users39 * async.times(5, function(n, next) {40 *     createUser(n, function(err, user) {41 *         next(err, user);42 *     });43 * }, function(err, users) {44 *     // we should now have 5 users45 * });46 */47function times(n, iteratee, callback) {48    return (0, _timesLimit2.default)(n, Infinity, iteratee, callback);49}50module.exports = exports.default;
basant307/AI_Governance_Project · CoolFace