• Process manga entries in smaller batches to avoid memory issues.

    Type Parameters

    • T

    Parameters

    • entries: KenmeiManga[]

      Array of Kenmei manga entries.

    • processFn: (batch: KenmeiManga[]) => Promise<T[]>

      Function to process each batch.

    • batchSize: number = 50

      Size of each batch.

    Returns Promise<T[]>

    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;
    }