promise concurrency

基于promise 并发控制

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greasyfork.org/scripts/488850/1336774/promise%20concurrency.js

Autor
我想吃鱼
Verzija
0.0.1.20240303042711
Napravljeno
03/03/2024
Ažurirano
03/03/2024
Licenca
Nije dostupno

使用方法

await concurrentTasks(5, [1, 2, 3, 4], (n) => {
  return new Promise((ok) => {
    setTimeout(() => {
      console.log(n);
      ok();
    }, Math.random() * 5000);
  });
});