Bluestep JS Documentation
    Preparing search index...

    Class DiffBuilder

    DiffBuilder is used to configure the differencing engine. Four different algorithms can be used to identify and mark differences by comparing a line at a time, a phrase at a time, a word at a time or character sequences. The find() function returns the [[Diff]] object with properties to explore and display the differences between the two input strings.

    See [[B.diff]]
    
    Index

    Constructors

    Methods

    • Start the differencing and returns the [[Diff]].

      Returns Diff

    • Unless turned off, lineDiff requests a line-by-line comparison. Line-by-line comparison is very different from other types of comparison for several reasons:

      1. The highlighting of differences uses background colors to show lines added (green), lines removed (red) and lines changed (blue). The other algorithms indicate things removed with strikeout and things added with bold.
      2. The result is forced into a fixed width font with no word wrapping.
      3. The differences within changed lines can be found and highlighted using one of the other diff algorithms.
      4. Since lines added are highlighted differently from lines removed, the order of original versus current/later is actually important. The highlighting style of the other diff algorithms is symmetrical for adds and removes, so the order of the inputs doesn't reallly matter.
      5. Line-base diff is designed to be viewed side-by-side showing original on the left and current on the right. With the other diff algorithms only one side of the diff result is normally displayed.

      The non-line-diff algorithms show changes with strikeout and bold. Text that is present in one String but not the other is displayed in both results, but shown with strikeout in the String where is wasn't present and bold in the String where it was present. If a bit of text has been replaced with another piece of text, the text from the opposite string is shown with strikeout, followed by the replacement text in bold. Using this type of highlighting it is not necessary to display both the original and current versions. Normally just the current version is shown since the highlighting shows all text from both versions.

      Returns DiffBuilder

    • This is a numeric, code value. If the sample value is -1, then a phrase-based diff will be used. If the sample value is 0 then a word-based diff will be used. If the sample is 1 or greater, then a character based diff will be used where the "sample" value is the minimum number of consecutive character that must match following a non-matching sequence and thus mark the end of the changed region. The default value is 0.

      If using the line-based diff, then in modified lines a secondary diff algorithm may run to find changes within each line. This parameter determines what diff algorithm will be used during the secondary phase.

      Parameters

      • sample: number

      Returns DiffBuilder

    • This is a floating-point value used exclusively by the line diff algorithm. It is a percentage between 0.0 and 100.0. When a line is found to be changed, then a secondary diff algorithm is used to find changes within the line. Sometimes the line is completely different, and sometimes only a small part of the line is changed. Most times when there is a complete change of the line to something different, there are still characters here and there or even whole words that match between the two separate lines. However, it looks ridiculous to mark the entire original line with strikeout (except for a single word or a few characters) and then show the entire current line in bold. The sensitivity parameter indicates what percent of the line must match the original before differences are highlighted. If sensitivity is 100.0 then a secondary diff is not even attempted because only a 100% match would cause the differences to be highlighted, and it's already been proven that the lines do not match 100%.

      Parameters

      • sensitivity: number

      Returns DiffBuilder