基于promise 并发控制
当前为
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/488850/1336774/promise%20concurrency.js
await concurrentTasks(5, [1, 2, 3, 4], (n) => {
return new Promise((ok) => {
setTimeout(() => {
console.log(n);
ok();
}, Math.random() * 5000);
});
});