• Move an element in an array from one index to another.

    Type Parameters

    • T

    Parameters

    • array: MutableArrayLike<T>

      The mutable array-like object of interest.

    • fromIndex: number

      The index of the element to move. Negative values are taken as an offset from the end of the array.

    • toIndex: number

      The target index of the element. Negative values are taken as an offset from the end of the array.

      Complexity

      Linear.

      Undefined Behavior

      A fromIndex or toIndex which is non-integral.

      Example

      import { ArrayExt } from from '@lumino/algorithm';

      let data = [0, 1, 2, 3, 4];
      ArrayExt.move(data, 1, 2); // [0, 2, 1, 3, 4]
      ArrayExt.move(data, 4, 2); // [0, 2, 4, 1, 3]

    Returns void