Skip to content

arrayBatch

arrayBatch<T>(inputArray, batchSize?): T[][]

Defined in: index.ts:281

Utility function to split an array into batches of a specified size.

T = any

T[]

number = 1

T[][]

const items = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
const batches = arrayBatch(items, 3)
// Output: [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]]

If batchSize is not a positive integer