(array1: T[], array2: T[])
| 74 | * @returns |
| 75 | */ |
| 76 | export function isSubSet<T extends number | string>(array1: T[], array2: T[]) { |
| 77 | if (!Array.isArray(array1) || !Array.isArray(array2)) { |
| 78 | return false; |
| 79 | } |
| 80 | const set1 = new Set(array1); |
| 81 | const set2 = new Set(array2); |
| 82 | if (set1.size > set2.size) { |
| 83 | return false; |
| 84 | } |
| 85 | for (const ele of set1) { |
| 86 | if (!set2.has(ele)) { |
| 87 | return false; |
| 88 | } |
| 89 | } |
| 90 | return true; |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * Is the intersection empty |