Skip to content

Diff Match Patch is a high-performance library in multiple languages that manipulates plain text.

License

Notifications You must be signed in to change notification settings

jrc03c/diff-match-patch

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Intro

This library is a JS-only fork of Google's diff-match-patch library. Please view the documentation there to learn more. I created this fork mainly to make the library easily installable via NPM. Please consult the NOTICE file for more information about the ways I changed the library from its original version.

Installation

npm install --save https://github.com/jrc03c/diff-match-patch

Usage

Import in Node or bundlers:

const { DiffMatchPatch } = require("@jrc03c/diff-match-patch")

Or import in the browser:

<!-- This defines `DiffMatchPatch` as a global variable -->
<script src="path/to/dist/diff-match-patch.js"></script>

Then:

const text1 = "Help!"
const text2 = "Hello!"
const dmp = new DiffMatchPatch()
const diff = dmp.diffMain(text1, text2)
console.log(dmp.diffLevenshtein(diff)) // 2

Testing

Eventually, I'd like to convert the tests into Jest format. But for now, you can run them with:

# unit tests
node tests/index.test.js

# speed tests
node tests/speed.test.js

About

Diff Match Patch is a high-performance library in multiple languages that manipulates plain text.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%