Skip to content

Latest commit

 

History

History
81 lines (47 loc) · 1.89 KB

File metadata and controls

81 lines (47 loc) · 1.89 KB

Class: String

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.

Method: fromChars(base, input)

Use this method to get the patch array from the string chars.

Syntax

const patches = Differs.String.fromChars(base, input);

Parameters

  • base, the base string, usually is the original/unchanged value.
  • input, the changed string that will be compared with the base string.

Return value

  • Returns the patch array where you can see in more details what is the diff between the base and input strings.

Method: fromWords(base, input)

Use this method to get the patches array from the string words.

Syntax

const patches = Differs.String.fromWords(base, input);

A split by white-spaces is automatically performed before the diff.

Parameters

  • base, the base string, usually is the original/unchanged value.
  • input, the changed string that will be compared with the base string.

Return value

  • Returns the patch array where you can see in more details what is the diff between the base and input strings.

Method: fromLines(base, input)

Get the patches array from the string lines.

Syntax

const patches = Differs.String.fromLines(base, input);

A split by LF and/or CF is automatically performed before the diff.

Parameters

  • base, the base string, usually is the original/unchanged value.
  • input, the changed string that will be compared with the base string.

Return value

  • Returns the patch array where you can see in more details what is the diff between the base and input strings.

Reference

Go Back

License

MIT