(aList, bList)
| 158 | } |
| 159 | |
| 160 | function diffSets(aList, bList) { |
| 161 | const a = new Map(); // canon -> count (multiset — duplicates matter) |
| 162 | const b = new Map(); |
| 163 | for (const x of aList) a.set(x, (a.get(x) ?? 0) + 1); |
| 164 | for (const x of bList) b.set(x, (b.get(x) ?? 0) + 1); |
| 165 | const onlyA = []; |
| 166 | const onlyB = []; |
| 167 | for (const [k, c] of a) { |
| 168 | const d = c - (b.get(k) ?? 0); |
| 169 | for (let i = 0; i < d; i++) onlyA.push(k); |
| 170 | } |
| 171 | for (const [k, c] of b) { |
| 172 | const d = c - (a.get(k) ?? 0); |
| 173 | for (let i = 0; i < d; i++) onlyB.push(k); |
| 174 | } |
| 175 | return { onlyA, onlyB }; |
| 176 | } |
| 177 | |
| 178 | // --- run ---------------------------------------------------------------------- |
| 179 | const buckets = new Map(); // category -> {count, samples[]} |
no test coverage detected