refactor: minimize review fixes

This commit is contained in:
ajnart committed 2026-08-22 09:04:17 +02:00
1 parent 396b78aa3e
commit 7a56a7d74f
3 files changed
+18 -35

No files matched your search

-23
View File
@@ -1,23 +0,0 @@
export async function mapWithConcurrency<T, U>(
values: readonly T[],
concurrency: number,
mapper: (value: T, index: number) => Promise<U>,
): Promise<U[]> {
if (!Number.isSafeInteger(concurrency) || concurrency < 1) {
throw new Error("Concurrency must be a positive integer");
}
const results: U[] = [];
let nextIndex = 0;
const workerCount = Math.min(concurrency, values.length);
const workers = Array.from({ length: workerCount }, async () => {
while (nextIndex < values.length) {
const index = nextIndex;
nextIndex += 1;
results[index] = await mapper(values[index] as T, index);
}
});
await Promise.all(workers);
return results;
}
-1
View File
@@ -13,4 +13,3 @@ export * from "./theme";
export * from "./function";
export * from "./grid-algorithm";
export * from "./id";
export * from "./async";