Files
mtdb_movie/common/resources/client/utils/array/prepend-to-array-at-index.ts
maher 703f50a09d
Some checks failed
Build / run (push) Has been cancelled
first commit
2025-10-29 11:42:25 +01: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];
}