(prev, curr)
| 208 | |
| 209 | // Bag diff: any summary appearing more in one bag than the other becomes added/removed. |
| 210 | function diffSummaries(prev, curr) { |
| 211 | const before = countBy(prev) |
| 212 | const after = countBy(curr) |
| 213 | const added = [] |
| 214 | const removed = [] |
| 215 | for (const summary of new Set([...before.keys(), ...after.keys()])) { |
| 216 | const b = before.get(summary) ?? 0 |
| 217 | const a = after.get(summary) ?? 0 |
| 218 | for (let i = 0; i < a - b; i += 1) added.push(summary) |
| 219 | for (let i = 0; i < b - a; i += 1) removed.push(summary) |
| 220 | } |
| 221 | return { added, removed } |
| 222 | } |
| 223 | |
| 224 | function formatDiff(added, removed) { |
| 225 | if (added.length === 0 && removed.length === 0) return null |
no test coverage detected