first commit
Some checks failed
Build / run (push) Has been cancelled

This commit is contained in:
maher
2025-10-29 11:42:25 +01:00
commit 703f50a09d
4595 changed files with 385164 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
import {clamp} from '../number/clamp';
export function moveItemInArray<T = any>(
array: T[],
fromIndex: number,
toIndex: number
): T[] {
const from = clamp(fromIndex, 0, array.length - 1);
const to = clamp(toIndex, 0, array.length - 1);
if (from === to) {
return array;
}
const target = array[from];
const delta = to < from ? -1 : 1;
for (let i = from; i !== to; i += delta) {
array[i] = array[i + delta];
}
array[to] = target;
return array;
}