• Limit an Array

    Type Parameters

    • Arr extends any[]
    • End extends unknown = "..."

    Parameters

    • input: Arr
    • length: number
    • Optional end: End

    Returns [...Arr, End]

    Example

    import { array } from "@rjweb/utils"

    array.limit([1, 2, 3, 4, 5, 6, 7], 5) // [1, 2, 3, 4, 5, '...']
    array.limit([1, 2, 3, 4, 5, 6, 7], 5, '!') // [1, 2, 3, 4, 5, '!']

    Since

    1.5.2

    Supports

    nodejs, browser