Files
mtdb_movie/common/resources/client/utils/array/prepend-to-array-at-index.ts
T
maher 511fad8199
Build / run (push) Has been cancelled
Initial commit
2026-05-14 13:42:10 +02:00

6 lines
211 B
TypeScript
Executable File

export function prependToArrayAtIndex<T>(array: T[], toAdd: T[], index = 0): T[] {
const copyOfArray = [...array];
const tail = copyOfArray.splice(index + 1);
return [...copyOfArray, ...toAdd, ...tail];
}