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


Ask a question, post a review, or report the script.
Author
我想吃鱼
Version
0.0.1.20240303042711
Created
2024-03-03
Updated
2024-03-03
Size
977 Bytes
License
N/A

使用方法

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