• Rotate an Array

    Type Parameters

    • Arr extends any[]

    Parameters

    • input: Arr
    • rotations: number

    Returns Arr

    Example

    import { array } from "@rjweb/utils"

    const arr = ['A', 'B', 'C', 'D', 'E']

    array.rotate(arr, 2) // ['C', 'D', 'E', 'A', 'B']
    array.rotate(arr, 4) // ['E', 'A', 'B', 'C', 'D']

    Since

    1.4.4

    Supports

    nodejs, browser