export const DEFAULT_BATCH_SIZE = 10000;
export async function runFunctionInBatches(arrayToBeBatched, functionToRun, batchSize = DEFAULT_BATCH_SIZE) {
    if (batchSize <= 0) {
        throw new Error('batchSize must be a positive number.');
    }
    const results = [];
    for(let i = 0; i < arrayToBeBatched.length; i += batchSize){
        const batch = arrayToBeBatched.slice(i, i + batchSize);
        const chunkedResult = await functionToRun(batch);
        for (const item of chunkedResult){
            results.push(item);
        }
    }
    return results;
}

//# sourceMappingURL=runFunctionInBatches.js.map