Skip to content

Finds differences between two JSON object and generates operational transformation (OT) operations for transforming the first object into the second according to the JSON0 OT Type.

Notifications You must be signed in to change notification settings

mainhanu/json0-ot-diff

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON0 OT Diff

Finds differences between two JSON object and generates operational transformation (OT) operations for transforming the first object into the second according to the JSON0 OT Type.

The current implementation supports list/object insertion/deletion (i.e. li, ld, oi, od) out of the box.

var jsondiff = require("./json0-ot-diff");

var diff = jsondiff(
	["foo", "bar", 1, 2, 3],
	["foo", "quux", 1, 2]
);
console.log(diff);

> [
>	{ p: [ 1 ], ld: 'bar', li: 'quux' },
>	{ p: [ 4 ], ld: 3 }
>]

String insertion/deletion (i.e. si, sd) operations are generated for string mutations if you provide a reference to diff-match-patch.

var diffMatchPatch = require("diff-match-patch");
var diff = jsondiff(
	["foo", "The only change here is at the end.", 1, 2, 3],
	["foo", "The only change here is at the very end.", 1, 2],
	diffMatchPatch
);
console.log(diff);

> [
> { p: [ 1, 31 ], si: 'very ' },
> { p: [ 4 ], ld: 3 }
>]

This was developed for JsonML with Webstrates in mind, but could be applicable in other situations.

About

Finds differences between two JSON object and generates operational transformation (OT) operations for transforming the first object into the second according to the JSON0 OT Type.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%