(array1: T[], array2: T[])
| 48 | * @returns |
| 49 | */ |
| 50 | export function isSameSet<T extends number | string>(array1: T[], array2: T[]) { |
| 51 | if (!Array.isArray(array1) || !Array.isArray(array2)) { |
| 52 | return false; |
| 53 | } |
| 54 | const set1 = new Set(array1); |
| 55 | const set2 = new Set(array2); |
| 56 | if (set1.size !== set2.size) { |
| 57 | return false; |
| 58 | } |
| 59 | for (const ele of set1) { |
| 60 | if (!set2.has(ele)) { |
| 61 | return false; |
| 62 | } |
| 63 | } |
| 64 | return true; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Check if array1 is a subset of array2 |
no test coverage detected