"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: Object.getOwnPropertyDescriptor(all, name).get
    });
}
_export(exports, {
    get DEFAULT_BATCH_SIZE () {
        return DEFAULT_BATCH_SIZE;
    },
    get runFunctionInBatches () {
        return runFunctionInBatches;
    }
});
const DEFAULT_BATCH_SIZE = 10000;
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