Core - v1.3.2
    Preparing search index...

    Class List

    Array helpers for splitting work into bounded batches.

    List.chunk([1, 2, 3, 4, 5], 2) // [[1, 2], [3, 4], [5]]
    

    Bayu Dwiyan Satria

    1.3.0

    1.3.0

    Index
    • Splits a list into consecutive batches of at most size elements.

      Type Parameters

      • T

        The element type.

      Parameters

      • values: readonly T[]

        The list to split. Not modified.

      • size: number

        Maximum batch length. Invalid sizes use one.

      Returns T[][]

      The batches in input order, or an empty array for empty input.

      Fractional sizes are truncated. Non-finite sizes and sizes below one use a batch size of one, keeping invalid configuration from producing an unbounded batch.