pols-utils - v5.3.11
    Preparing search index...

    Function chunks

    • Split an array into smaller chunks. Each chunk will have a maximum length defined by the length parameter.

      Type Parameters

      • T

        The type of elements in the array.

      Parameters

      • array: T[]

        The target array.

      • length: number

        The maximun length of each chunk.

      Returns T[][]

      An array of chunks.

      const mynumbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
      console.log(PUtilsArray.chunks(mynumbers, 3))
      // [
      // [0, 1, 2],
      // [3, 4, 5],
      // [6, 7, 8],
      // [9],
      // ]