(a: string, b: string)
| 1 | export 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 | } |