( a: string | readonly string[], b: string | readonly string[], )
| 50 | * Test equality for arrays of strings or a string. |
| 51 | */ |
| 52 | export function equalArraysOrString( |
| 53 | a: string | readonly string[], |
| 54 | b: string | readonly string[], |
| 55 | ): boolean { |
| 56 | if (Array.isArray(a) && Array.isArray(b)) { |
| 57 | if (a.length !== b.length) return false; |
| 58 | const aSorted = [...a].sort(); |
| 59 | const bSorted = [...b].sort(); |
| 60 | return aSorted.every((val, index) => bSorted[index] === val); |
| 61 | } else { |
| 62 | return a === b; |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Return the last element of an array. |
no test coverage detected
searching dependent graphs…