(a: string, b: string)
| 4 | // stolen from https://github.com/octavore/delta/blob/master/lib/histogram.go |
| 5 | // HistogramDiff uses the histogram diff algorithm to generate a line-based diff between two strings |
| 6 | export function histogramDiff(a: string, b: string): DiffPair[] { |
| 7 | if (a.length + b.length === 0) { |
| 8 | return []; |
| 9 | } else if (a.length === 0) { |
| 10 | return [{ right: newDiff(0, b.length, "ins") }]; |
| 11 | } else if (b.length === 0) { |
| 12 | return [{ left: newDiff(0, a.length, "del") }]; |
| 13 | } |
| 14 | |
| 15 | const aa = a.split("\n"); |
| 16 | const bb = b.split("\n"); |
| 17 | return new HistogramDiffer(aa, bb).solve(); |
| 18 | } |
| 19 | |
| 20 | // Histogram of lines. |
| 21 | class Histogram { |
no test coverage detected