const arrayMove = (array: T, from: number, to: number) => { const newArray = [...array]; const startIndex = from < 0 ? array.length + from : from; if (startIndex >= 0 && startIndex < array.length) { const endIndex = to < 0 ? array.length + to : to; const [item] = newArray.splice(from, 1); newArray.splice(endIndex, 0, item); } return newArray; }; export default arrayMove;