MCPcopy
hub / github.com/codeceptjs/CodeceptJS / diffSummaries

Function diffSummaries

lib/aria.js:210–222  ·  view source on GitHub ↗
(prev, curr)

Source from the content-addressed store, hash-verified

208
209// Bag diff: any summary appearing more in one bag than the other becomes added/removed.
210function 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
224function formatDiff(added, removed) {
225 if (added.length === 0 && removed.length === 0) return null

Callers 1

diffAriaSnapshotsFunction · 0.85

Calls 3

countByFunction · 0.85
getMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected