Files
mtdb_movie/common/resources/client/utils/array/move-item-in-new-array.ts
maher 703f50a09d
Some checks failed
Build / run (push) Has been cancelled
first commit
2025-10-29 11:42:25 +01:00

15 lines
250 B
TypeScript
Executable File

export function moveItemInNewArray<T>(
array: T[],
from: number,
to: number
): T[] {
const newArray = array.slice();
newArray.splice(
to < 0 ? newArray.length + to : to,
0,
newArray.splice(from, 1)[0]
);
return newArray;
}