Constructs a new DiffChecker instance for comparing two texts.
The first (original) text
The second (modified) text
Optionalopt: DiffOptions = {}Optional diff configuration
Private ReadonlyaOriginal input texts and options
Private ReadonlybPrivatediffFlag to indicate if the diff has already been computed
PrivateentriesComputed diff entries and groups
PrivategroupedPrivate ReadonlyoptionsPrivatecomputeComputes the diff between the two input texts and populates the entries and grouped arrays.
PrivateconcatConcatenates an array of tokens back into a string, respecting the diff mode.
Array of tokens
PrivatefindGroups adjacent changed lines together, including context lines, and calculates group metrics.
Returns the unified diff as a plain ASCII string.
Returns the unified diff as a CLI-colored string.
Returns the grouped diff as an array of DiffGroup objects.
Returns the structured diff as an array of DiffLine objects.
PrivatelineCompares two lines and records their differences at the configured granularity.
Line from the first text
Line from the second text
Line number
PrivatemagnitudeCalculates the change magnitude string for a group or line.
Number of deleted characters
Number of inserted characters
Base length for normalization
PrivateoutputGenerates a unified diff output as a string, with optional CLI coloring.
If true, use CLI colors; otherwise, ASCII markup
PrivatepreciseFinds all minimal diff blocks between two tokenized strings, returning original text and positions.
Original line (case preserved)
Original line (possibly lowercased)
Modified line (case preserved)
Modified line (possibly lowercased)
Privatetext2linesSplits both input texts into arrays of lines and returns them with the maximum line count.
PrivatetokenizeTokenizes a string according to the current diff mode (line or word).
The string to tokenize
The DiffChecker class provides methods to compare two texts and generate structured diffs, grouped diffs, and unified diff outputs.