UNPKG

diginext-utils

Version:
18 lines 644 B
/** * Moves an element from one index to another in an array. * Returns a new array without modifying the original. * * @template T - The type of elements in the array * @param array - The array to modify * @param fromIndex - The index of the element to move * @param toIndex - The index to move the element to * @returns A new array with the element moved * * @example * ```ts * moveElement([1, 2, 3, 4], 0, 2); // [2, 3, 1, 4] * moveElement(['a', 'b', 'c'], 2, 0); // ['c', 'a', 'b'] * ``` */ export declare function moveElement<T>(array: T[], fromIndex: number, toIndex: number): T[]; //# sourceMappingURL=moveElement.d.ts.map