@trashpanda001/helpers
    Preparing search index...

    Function chunkEvery

    • Breaks an array into chunks of size chunkSize.

      The last chunk may contain less than chunkSize items.

      Type Parameters

      • T

      Parameters

      • array: readonly T[]

        the array to chunk

      • chunkSize: number

        a positive integer

      Returns T[][]

      an array of arrays

      Chunk into groups of 2.

      import { chunkEvery } from "@trashpanda001/helpers/array"

      chunkEvery([1, 2, 3, 4, 5], 2)
      // [[1, 2], [3, 4], [5]]