( currentArray: T[], targetArray: T[], currentIndex: number, targetIndex: number, )
| 61 | * |
| 62 | */ |
| 63 | export function copyArrayItem<T = any>( |
| 64 | currentArray: T[], |
| 65 | targetArray: T[], |
| 66 | currentIndex: number, |
| 67 | targetIndex: number, |
| 68 | ): void { |
| 69 | const to = clamp(targetIndex, targetArray.length); |
| 70 | |
| 71 | if (currentArray.length) { |
| 72 | targetArray.splice(to, 0, currentArray[currentIndex]); |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | /** Clamps a number between zero and a maximum. */ |
| 77 | function clamp(value: number, max: number): number { |
no test coverage detected