Text diff algorithm based on 'An O(NP) Sequence Comparison Algorithm' from Sun Wu, Udi Manber and Gene Myers
![ONP][logo] ONP
======
[![Pipeline][pipeline]][link-pipeline]
[![Npm][npm-version]][link-npm]
[![Downloads][npm-downloads]][link-npm]
[![License][license]][link-license]
[![Node][node]][link-node]
[![Collaborators][collaborators]][link-npm]
.toString() and keep original objects and instances. It's has really simple API.
npm install onp
`
$3
#### diffText(a: string, b: string): [DiffText][DiffText]
This method take 2 string and make compare of these strings. It returns object with
lcs property, that is contains ["longest common subsequence"][ext-link-lcs] text,
distance property that represents ["Levenshtein distance"][ext-link-levenshtein_distance] and
results property that contains array with string and state (1, 0, -1)
#### diffArray [DiffArray][DiffArray]
This method take 2 array of objects, that has implemented method .toString() and make
compare of these objects based on .toString() result. This method try to keep instances of
objects as valid as possible. It returns object with
lcs property, that is contains ["longest common subsequence"][ext-link-lcs] text,
distance property that represents ["Levenshtein distance"][ext-link-levenshtein_distance] and
results property that contains array with items of T and state (1, 0, -1)
##### Typescript usage example
`typescript
import {diffText} from "onp";
const results = diffText("Text A", "Text B");
console.log(results.distance);
//2
console.log(results.lcs);
//"Text "
console.log(results.results);
//[
// { left: 'Text ', right: 'Text ', state: 0 },
// { left: 'A', right: 'A', state: -1 },
// { left: 'B', right: 'B', state: 1 }
//]
`
##### Javascript usage example
`javascript
const diffText = require("onp").diffText;
const results = diffText("Text A", "Text B");
console.log(results.distance);
//2
console.log(results.lcs);
//"Text "
console.log(results.results);
//[
// { left: 'Text ', right: 'Text ', state: 0 },
// { left: 'A', right: 'A', state: -1 },
// { left: 'B', right: 'B', state: 1 }
//]
`
`javascript
const results = onp.diffText("Text A", "Text B");
console.log(results.distance);
//2
console.log(results.lcs);
//"Text "
console.log(results.results);
//[
// { left: 'Text ', right: 'Text ', state: 0 },
// { left: 'A', right: 'A', state: -1 },
// { left: 'B', right: 'B', state: 1 }
//]
``