@pengzhanbo/utils - v3.4.1
    Preparing search index...

    Function chunk

    • Split array into chunks

      将数组拆分成块

      Type Parameters

      • T

      Parameters

      • input: T[]

        The array to be chunked. 要分块的数组

      • size: number = 1

        The size of each chunk. Defaults to 1. 每个块的大小,默认为1

      Returns T[][]

      A new array of chunks. 分块后的新数组

      chunk([1, 2, 3, 4, 5], 2) // => [[1, 2], [3, 4], [5]]