File size: 449 Bytes
c09f67c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | // @ts-nocheck
export async function processPromisesBatch(items: any, limit: number, fn) {
const batches = [];
let result: any = [];
// Split the items into batches
for (let i = 0; i < items?.length; i += limit) {
batches.push(items.slice(i, i + limit));
}
// Process batches serially
for (const batch of batches) {
const processedBatch = await fn(batch);
result = result.concat(processedBatch);
}
return result;
}
|