Provide a set of methods for working with strings performing all diff steps at once.
All examples will use the following variables:
import * as Differs from '@balmanth/differs';
const base = 'Example'; // Base string.
const input = 'eXAMPLe'; // Input string.Use this method to get the patch array from the string chars.
const patches = Differs.String.fromChars(base, input);- base, the base string, usually is the original/unchanged value.
- input, the changed string that will be compared with the base string.
- Returns the patch array where you can see in more details what is the diff between the base and input strings.
Use this method to get the patches array from the string words.
const patches = Differs.String.fromWords(base, input);A split by white-spaces is automatically performed before the diff.
- base, the base string, usually is the original/unchanged value.
- input, the changed string that will be compared with the base string.
- Returns the patch array where you can see in more details what is the diff between the base and input strings.
Get the patches array from the string lines.
const patches = Differs.String.fromLines(base, input);A split by LF and/or CF is automatically performed before the diff.
- base, the base string, usually is the original/unchanged value.
- input, the changed string that will be compared with the base string.
- Returns the patch array where you can see in more details what is the diff between the base and input strings.