Diff-Match-Patch in Typescript with full budget and surrogate pairs support
Javascript diff-match-patch, made suitable for use in production:
- Modern typescript with unit tests, thanks to diff-match-patch-typescript.
- Full unicode support, thanks to PR 80
- I added full diffTimeout support, which is only partially implemented elsewhere, and is critical for production use (since otherwise your server or browser can be easily stuck at 100% for minutes). See big.test.ts.
- Modern api for creating dmp object (still backward compatible).
Installation
pnpm i @cocalc/diff-match-patch
import { DiffMatchPatch } from "@cocalc/diff-match-patch";
const dmp = new DiffMatchPatch({ diffTimeout:0.5 });
const patch = dmp.patch_make("ello", "hello world");
console.log(JSON.stringify(patch));
dmp.patch_apply(patch, "ello");
Documentation
Official Repository.