(array: T[], from: number, to: number)
| 26 | * @returns {(T[] | boolean)} |
| 27 | */ |
| 28 | export function moveArrayElement<T>(array: T[], from: number, to: number): boolean { |
| 29 | const length = array.length; |
| 30 | |
| 31 | if (from < 0 || from >= length || to < 0 || to >= length || from === to) { |
| 32 | return false; |
| 33 | } |
| 34 | |
| 35 | const fromItem = array[from]!; |
| 36 | |
| 37 | array.splice(from, 1); |
| 38 | array.splice(to, 0, fromItem); |
| 39 | |
| 40 | return true; |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Check if array1 and array2 are the same set |
no outgoing calls
no test coverage detected