fn
move
v0.0.10testedReturn a new array with the item at `from` moved to `to`. Out-of-range `from` returns a shallow copy unchanged; `to` is clamped into range. Never mutates.
Example
ts
move(['a', 'b', 'c'], 0, 2); // ['b', 'c', 'a']Signature
ts
export function move<T>(array: readonly T[], from: number, to: number): T[]{ ... }Type Parameters
TParameters
| Parameter | Type | Description |
|---|---|---|
array | readonly T[] | The source array |
from | number | Index to move from |
to | number | Index to move from |
Returns
T[]A new array with the item moved