mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
12 lines
307 B
TypeScript
12 lines
307 B
TypeScript
export function reorderArray<T>(array: T[], from: number, to: number): T[] {
|
|
const newArray = [...array];
|
|
if (from < to) {
|
|
newArray.splice(to, 0, array[from]!);
|
|
newArray.splice(from, 1);
|
|
} else {
|
|
newArray.splice(from, 1);
|
|
newArray.splice(to, 0, array[from]!);
|
|
}
|
|
return newArray;
|
|
}
|