1.0.0 • Published 8 years ago

dmp v1.0.0

Weekly downloads
87
License
-
Repository
github
Last release
8 years ago

DMP: Diff Match Patch

Development status: Production-ready.

Node.js module based on Neil Fraiser's excellent Diff Match Patch.

npm version

Build Status

Floobits Status

Install

Add dmp to your package.json or npm install dmp.

This module requires Node.js v4.0 or later.

Use

const DMP = require("dmp");
const dmp = new DMP();

let patches = dmp.patch_make("", "abcd");

console.log(dmp.patch_toText(patches));
// @@ -0,0 +1,4 @@
// +abcd

let patch_text = "@@ -0,0 +1,4 @@\n+abcd\n";
patches = dmp.patch_fromText(patch_text);

let result = dmp.patch_apply(patches, "");
console.log(result);
// [ 'abcd', [ true ] ]

Configure

After creating a DMP object, you can tweak a few attributes. Don't mess with these unless you know what you're doing!

dmp.Patch_DeleteThreshold = 0.375;
dmp.Match_Threshold = 0.375;
dmp.Match_Distance = 100;

Default values are:

Patch_DeleteThreshold = 0.5;
Match_Threshold = 0.5;
Match_Distance = 1000;
1.0.0

8 years ago

0.2.0

8 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago