UNPKG

@autobe/agent

Version:

AI backend server code generator

24 lines (23 loc) 1.02 kB
/** * Divides an array into chunks of at most `capacity` elements each for parallel * batch processing. * * Used with `executeCachedBatch` to split large task lists into smaller batches * that can be processed concurrently. The `capacity` parameter controls the * maximum number of elements per chunk, not the number of chunks. This enables * balancing parallelism against prompt cache efficiency. * * For example, dividing 100 operations with capacity=3 creates 34 chunks of 3 * operations each (the last chunk may have fewer elements if the array length * is not a multiple of capacity). This allows processing 100 operations in 34 * parallel batches of up to 3 operations each. * * @param props Object containing the array to divide and the maximum chunk size * (`capacity`) * @returns Array of chunks with at most `capacity` elements each * @throws Error if capacity is non-positive, NaN, or Infinity */ export declare function divideArray<T>(props: { array: T[]; capacity: number; }): T[][];