A class for performing diffs. Wraps the DiffMatchPatch class from the original library with more
ergonomic and Unicode-friendly methods.
Differ(config?: Partial<DiffMatchPatchConfig>)
cleanupSemantic(diffs: Diff[]): Diff[]
Cleanup function to increase human readability by factoring out commonalities which are likely to be coincidental.
Diff two strings. Fully Unicode-aware by default.
Pass a segmenter option to customize the units of calculation for the diff (char, line, word, grapheme, sentence,
etc).
diffCodeUnits(): Diff[]
Diff two strings by UTF-16 code unit. May not work as expected for non-BMP characters. This is simply a wrapper
around diff-match-patch's diff_main, which may be a preferable way to create char diffs compared to
diff where full Unicode support is not critical and in performance-sensitive scenarios.
diffWithin(diffs: Diff[],options?: Partial<DiffOptions>,): Diff[][]
Convert an less-granular array of diffs to a 2d array of more-granular diffs-within-diffs.
For example, get word diffs within line diffs.