UNPKG

apphouse

Version:

Component library for React that uses observable state management and theme-able components.

16 lines (15 loc) 523 B
/** * Swaps two elements in a list * @param list is the array in which you want to swap the items. * @param index1 index of the element you want to swap * @param index2 index of the element you want to swap * @returns a new list with the updated order after the swap operation * * @usage * ```typescript * const myList = [1, 2, 3, 4, 5]; * swapItems(myList, 2, 4); * console.log(myList); // Output: [1, 2, 5, 4, 3] * ``` */ export declare function swapItems<T>(list: T[], index1: number, index2: number): T[];