MCPcopy Index your code
hub / github.com/node-modules/utility / spliceOne

Function spliceOne

src/array.ts:25–44  ·  view source on GitHub ↗
(arr: T[], index: number)

Source from the content-addressed store, hash-verified

23 * @return {Array} the array instance
24 */
25export function spliceOne<T = any>(arr: T[], index: number): T[] {
26 if (index < 0) {
27 index = arr.length + index;
28 // still negative, not found element
29 if (index < 0) {
30 return arr;
31 }
32 }
33
34 // don't touch
35 if (index >= arr.length) {
36 return arr;
37 }
38
39 for (let i = index, k = i + 1, n = arr.length; k < n; i += 1, k += 1) {
40 arr[i] = arr[k];
41 }
42 arr.pop();
43 return arr;
44}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…