1.0.5 • Published 4 years ago

lcs-diff v1.0.5

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

lcs-diff

A tool to compare the difference between two lists

Example

Preview link https://liaokaime.github.io/lcs-diff/

Installation

npm i lcs-diff

Usage

import {LCS} from "lcs-diff/dist";

let lcs =new LCS({
    content : {
        listA : ["a","b","c","d"],
        listB : ["b","c","d","e"],
    },
    compare : (t1,t2)=>{
        return t1 === t2
    }
});

/**
 * Gets the difference between two pieces of text.
 *   The return value is an array with 3 keys for each element.
 *   "unitA" and "unitB" are elements from listA and listB, When "unitA" or "unitB" do not match element from another list, they may be undefined.
 *   "equals" indicates whether "unitA" and "unitB" are the same
 *   {
 *       unitA : T | undefined,
 *       unitB : T | undefined,
 *       equals : boolean
 *   }
 */
let compareList = lcs.getDiff();

/**
 * Gets the similarity between the contents of the two lists
 * This is a number between 0 and 1
 */
let similarity = lcs.getSimilarity();

License

The files included in this repository are licensed under the MIT license.

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago