Files
sentinel/static/app/utils/replaceAtArrayIndex.tsx
2024-02-15 17:01:50 +00:00

9 lines
224 B
TypeScript

/**
* Replace item at `index` in `array` with `obj`
*/
export function replaceAtArrayIndex<T>(array: T[], index: number, obj: T): T[] {
const newArray = [...array];
newArray.splice(index, 1, obj);
return newArray;
}