5
common/resources/client/utils/array/prepend-to-array-at-index.ts
Executable file
5
common/resources/client/utils/array/prepend-to-array-at-index.ts
Executable file
@@ -0,0 +1,5 @@
|
||||
export function prependToArrayAtIndex<T>(array: T[], toAdd: T[], index = 0): T[] {
|
||||
const copyOfArray = [...array];
|
||||
const tail = copyOfArray.splice(index + 1);
|
||||
return [...copyOfArray, ...toAdd, ...tail];
|
||||
}
|
||||
Reference in New Issue
Block a user