Array of Kenmei manga entries.
Function to process each batch.
Size of each batch.
Aggregated results.
export async function processMangaInBatches<T>(
entries: KenmeiManga[],
processFn: (batch: KenmeiManga[]) => Promise<T[]>,
batchSize = 50,
): Promise<T[]> {
const results: T[] = [];
// Process in batches
for (let i = 0; i < entries.length; i += batchSize) {
const batch = entries.slice(i, i + batchSize);
const batchResults = await processFn(batch);
results.push(...batchResults);
}
return results;
}
Process manga entries in smaller batches to avoid memory issues.