@eroyeroy/utils - v0.1.0
    Preparing search index...

    Function moveArrayItem

    • Returns a new array with the item at fromIndex moved to toIndex.

      Type Parameters

      • T

      Parameters

      • array: readonly T[]

        The source array.

      • fromIndex: number

        Current index of the item to move.

      • toIndex: number

        Target index.

      Returns T[]

      moveArrayItem([1, 2, 3, 4], 0, 3) // => [2, 3, 4, 1]
      moveArrayItem([1, 2, 3, 4], 3, 0) // => [4, 1, 2, 3]