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

نووسەر
我想吃鱼
وەشان
0.0.1.20240303042711
Created
2024-03-03
Updated
2024-03-03
مۆڵەت
نییە

使用方法

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