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.greatest.deepsurf.us/scripts/488850/1336774/promise%20concurrency.js

Аўтар
我想吃鱼
Версія
0.0.1.20240303042711
Створаны
03.03.2024
Абноўлены
03.03.2024
Памер
977 байтаў
Ліцэнзія
Н/Д

使用方法

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