MCPcopy Create free account
hub / github.com/Snapchat/Valdi / insert

Function insert

src/valdi_modules/src/valdi/foundation/src/array.ts:22–24  ·  view source on GitHub ↗
(arr: T[], index: number, newItem: T)

Source from the content-addressed store, hash-verified

20 * Immutable insert function
21 */
22export function insert<T>(arr: T[], index: number, newItem: T): T[] {
23 return [...arr.slice(0, index), newItem, ...arr.slice(index)];
24}
25
26/*
27 * Immutable multiInsert function that inserts values into an array at given indeces

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected