plainfp - v0.1.0
    Preparing search index...

    Function chunk

    • Split xs into consecutive slices of length size. The last slice may be shorter if the length isn't divisible.

      Dual API — works data-first or curried for use in pipe.

      Type Parameters

      • T

      Parameters

      • xs: readonly T[]
      • size: number

      Returns T[][]

      RangeError if size is not a positive integer (fractional, zero, or negative values all reject).

      chunk([1, 2, 3, 4, 5], 2)
      // [[1, 2], [3, 4], [5]]
    • Split xs into consecutive slices of length size. The last slice may be shorter if the length isn't divisible.

      Dual API — works data-first or curried for use in pipe.

      Type Parameters

      • T

      Parameters

      • size: number

      Returns (xs: readonly T[]) => T[][]

      RangeError if size is not a positive integer (fractional, zero, or negative values all reject).

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