2 * Returns a new array with the item moved to the new position.
3 * @param list List of items
4 * @param from Index of item to move. If negative, it will begin that many elements from the end.
5 * @param to Index of where to move the item. If negative, it will begin that many elements from the end.
6 * @return New array with the item moved to the new position
8 const move = <T>(list: T[] = [], from: number, to: number) => {
9 const copy = list.slice();
10 copy.splice(to < 0 ? copy.length + to : to, 0, copy.splice(from, 1)[0]);