MCPcopy Create free account
hub / github.com/Linen-dev/linen.dev / move

Function move

packages/utilities/src/array.ts:1–10  ·  view source on GitHub ↗
(array: any[], from: number, to: number)

Source from the content-addressed store, hash-verified

1export function move(array: any[], from: number, to: number) {
2 const max = array.length - 1;
3 if (from > max || to > max || from < 0 || to < 0) {
4 return array;
5 }
6 const copy = [...array];
7 const item = copy.splice(from, 1)[0];
8 copy.splice(to, 0, item);
9 return copy;
10}
11
12export function unionBy(
13 array1: { [key: string]: any }[],

Callers 2

array.test.tsFile · 0.90
reorderChannelsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected