Giter VIP home page Giter VIP logo

json0-ot-diff's Introduction

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.

json0-ot-diff's People

Contributors

curran avatar dependabot[bot] avatar j-c-levin avatar kbadk avatar mainhanu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.