MCPcopy Create free account
hub / github.com/apitable/apitable / moveArrayElement

Function moveArrayElement

packages/core/src/utils/array.ts:28–41  ·  view source on GitHub ↗
(array: T[], from: number, to: number)

Source from the content-addressed store, hash-verified

26 * @returns {(T[] | boolean)}
27 */
28export function moveArrayElement<T>(array: T[], from: number, to: number): boolean {
29 const length = array.length;
30
31 if (from < 0 || from >= length || to < 0 || to >= length || from === to) {
32 return false;
33 }
34
35 const fromItem = array[from]!;
36
37 array.splice(from, 1);
38 array.splice(to, 0, fromItem);
39
40 return true;
41}
42
43/**
44 * Check if array1 and array2 are the same set

Callers 9

dragGroupFunction · 0.90
onSortEndFunction · 0.90
onDragEndFunction · 0.90
onMoveFunction · 0.90
handleDropFunction · 0.90
afterDragFunction · 0.90
handleSortViewFunction · 0.90
handleDragEndFunction · 0.90
array.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected