LittleDemon WebShell


Linux premium331.web-hosting.com 4.18.0-553.80.1.lve.el8.x86_64 #1 SMP Wed Oct 22 19:29:36 UTC 2025 x86_64
Path : /home/livedhms/lmgt/node_modules/mongoose/lib/helpers/
File Upload :
Command :
Current File : /home/livedhms/lmgt/node_modules/mongoose/lib/helpers/parallelLimit.js

'use strict';

module.exports = parallelLimit;

/*!
 * ignore
 */

async function parallelLimit(params, fn, limit) {
  if (limit <= 0) {
    throw new Error('Limit must be positive');
  }

  if (params.length === 0) {
    return [];
  }

  const results = [];
  const executing = new Set();

  for (let index = 0; index < params.length; index++) {
    const param = params[index];
    const p = fn(param, index);
    results.push(p);

    executing.add(p);

    const clean = () => executing.delete(p);
    p.then(clean).catch(clean);

    if (executing.size >= limit) {
      await Promise.race(executing);
    }
  }

  return Promise.all(results);
}

LittleDemon - FACEBOOK
[ KELUAR ]