( currentArray: T[], targetArray: T[], currentIndex: number, targetIndex: number, )
| 38 | * @param targetIndex Index at which to insert the item. |
| 39 | */ |
| 40 | export function transferArrayItem<T = any>( |
| 41 | currentArray: T[], |
| 42 | targetArray: T[], |
| 43 | currentIndex: number, |
| 44 | targetIndex: number, |
| 45 | ): void { |
| 46 | const from = clamp(currentIndex, currentArray.length - 1); |
| 47 | const to = clamp(targetIndex, targetArray.length); |
| 48 | |
| 49 | if (currentArray.length) { |
| 50 | targetArray.splice(to, 0, currentArray.splice(from, 1)[0]); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Copies an item from one array to another, leaving it in its |
no test coverage detected