Skip to content

A tool to compare the difference between two lists

Notifications You must be signed in to change notification settings

liaokaime/lcs-diff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A tool to compare the difference between two lists

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published