MCPcopy Create free account
hub / github.com/DefiLlama/chainlist / arrayMove

Function arrayMove

utils/fetch.js:88–100  ·  view source on GitHub ↗
(array, fromIndex, toIndex)

Source from the content-addressed store, hash-verified

86}
87
88export function arrayMove(array, fromIndex, toIndex) {
89 const newArray = [...array];
90 const startIndex = fromIndex < 0 ? newArray.length + fromIndex : fromIndex;
91
92 if (startIndex >= 0 && startIndex < newArray.length) {
93 const endIndex = toIndex < 0 ? newArray.length + toIndex : toIndex;
94 const [item] = newArray.splice(fromIndex, 1);
95
96 newArray.splice(endIndex, 0, item);
97 }
98
99 return newArray;
100}
101
102function getBaseName(name) {
103 if (!name) return "";

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected