2025-04-24 17:03:28 +08:00

21 lines
269 B
JavaScript

/**
* Expose `thread`.
*/
module.exports = thread;
/**
* Run `fn` `n` times in parallel.
*
* @param {Function} fn
* @param {Number} n
* @return {Array}
* @api public
*/
function thread(fn, n) {
var gens = [];
while (n--) gens.push(fn);
return gens;
}