(array1: T[], array2: T[])
| 100 | * @returns |
| 101 | */ |
| 102 | export function hasIntersect<T extends number | string>(array1: T[], array2: T[]) { |
| 103 | if (!Array.isArray(array1) || !Array.isArray(array2)) { |
| 104 | return false; |
| 105 | } |
| 106 | const set1 = new Set(array1); |
| 107 | const set2 = new Set(array2); |
| 108 | |
| 109 | for (const ele of set1) { |
| 110 | if (set2.has(ele)) { |
| 111 | return true; |
| 112 | } |
| 113 | } |
| 114 | return false; |
| 115 | } |
| 116 | |
| 117 | export function array2Map<T>(arr: T[], key: string) { |
| 118 | return arr.reduce((obj: {}, element: T) => { |
no test coverage detected