MCPcopy Create free account
hub / github.com/ChromeDevTools/devtools-frontend / formatDiff

Function formatDiff

test/conductor/diff-utils.ts:22–44  ·  view source on GitHub ↗
(
        diffBlocks: Array<{value: string, added: boolean, removed: boolean}>, onSame: DiffCallback,
        onAdded: DiffCallback, onRemoved: DiffCallback)

Source from the content-addressed store, hash-verified

20}
21
22export function*
23 formatDiff(
24 diffBlocks: Array<{value: string, added: boolean, removed: boolean}>, onSame: DiffCallback,
25 onAdded: DiffCallback, onRemoved: DiffCallback) {
26 for (const block of diffBlocks) {
27 const lines = block.value.split('\n').filter(l => l.length > 0);
28 if (!block.added && !block.removed && lines.length > 3) {
29 yield onSame(lines[0]);
30 yield onSame(' ...');
31 yield onSame(lines[lines.length - 1]);
32 } else {
33 for (const line of lines) {
34 if (block.added) {
35 yield onAdded(line);
36 } else if (block.removed) {
37 yield onRemoved(line);
38 } else {
39 yield onSame(line);
40 }
41 }
42 }
43 }
44}
45
46export function resultAssertionsDiff(assertionErrors: any[]) {
47 if (!assertionErrors || assertionErrors.length === 0) {

Callers 2

formatDiffTextFunction · 0.85
formatAsPatchFunction · 0.85

Calls 2

splitMethod · 0.80
filterMethod · 0.45

Tested by

no test coverage detected