Files
maher 511fad8199
Build / run (push) Has been cancelled
Initial commit
2026-05-14 13:42:10 +02: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;
}