Options
All
  • Public
  • Public/Protected
  • All
Menu

Module chunk

Index

References

Functions Array

References

Renames and re-exports chunk

Array Functions

  • chunk<T>(array: T[], size?: number): T[][]
  • Creates an array of elements split into groups the length of size. If array can't be split evenly, the final chunk will be the remaining elements.

    since

    5.18.0

    example
    chunk(['a', 'b', 'c', 'd'], 2)
    // => [['a', 'b'], ['c', 'd']]

    chunk(['a', 'b', 'c', 'd'], 3)
    // => [['a', 'b', 'c'], ['d']]

    Type Parameters

    • T

    Parameters

    • array: T[]

      The array to process.

    • size: number = 1

      The length of each chunk, default is 1

    Returns T[][]

    Returns the new array of chunks.