This commit is contained in:
张成
2026-03-18 17:42:38 +08:00
parent bc1068ec66
commit 18aa083c91
6 changed files with 96 additions and 43 deletions

View File

@@ -2,9 +2,8 @@ export async function sleep_ms(ms) {
await new Promise((resolve) => setTimeout(resolve, ms));
}
export async function map_limit(items, limit, worker) {
export async function map_limit(items, worker) {
const list = Array.isArray(items) ? items : [];
const n = Math.max(1, Number(limit || 1));
const res = new Array(list.length);
let idx = 0;
@@ -18,7 +17,7 @@ export async function map_limit(items, limit, worker) {
}
const runners = [];
for (let i = 0; i < Math.min(n, list.length); i += 1) {
for (let i = 0; i < list.length; i += 1) {
runners.push(run_one());
}