MCPcopy
hub / github.com/bombshell-dev/clack / diffLines

Function diffLines

packages/core/src/utils/string.ts:1–19  ·  view source on GitHub ↗
(a: string, b: string)

Source from the content-addressed store, hash-verified

1export function diffLines(a: string, b: string) {
2 if (a === b) return;
3
4 const aLines = a.split('\n');
5 const bLines = b.split('\n');
6 const numLines = Math.max(aLines.length, bLines.length);
7 const diff: number[] = [];
8
9 for (let i = 0; i < numLines; i++) {
10 if (aLines[i] !== bLines[i]) diff.push(i);
11 }
12
13 return {
14 lines: diff,
15 numLinesBefore: aLines.length,
16 numLinesAfter: bLines.length,
17 numLines,
18 };
19}

Callers 1

renderMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected