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