1
2
3
4
5
6
7
| export function moveListItem<T>(list: T[], oldIndex?: null | number, newIndex?: null | number) {
| if (oldIndex == null || newIndex == null || oldIndex === newIndex || oldIndex < 0 || newIndex < 0 || oldIndex >= list.length || newIndex >= list.length) {
| return;
| }
| const [item] = list.splice(oldIndex, 1);
| if (item !== undefined) list.splice(newIndex, 0, item);
| }
|
|