Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including googlediff with all npm packages installed. Try it out:

var googlediff = require("googlediff")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

googlediff v0.1.0

Simple packaging of Neil Fraser's original google-diff-match-patch

node module for: by Neil Fraser and contributors.

drop in the original code form svn of Neil Fraser's diff_match_patch. uses jsinc and a simple index.js file and thus it is easily updatable

to update just copy in here the 'demos' and 'javascript' folders

this module is also awesome because you can use exactrly the same code on the serverside and on the client side.

this module is built using

the test tests just that the modue is usable.

see demos to learn how it works.

by Shimon Dookdin

may be intalled with npm:

npm install googlediff

demo: var diff_match_patch=require('googlediff');

var dmp =new diff_match_patch();
function launch() {
  var text1 = "this is some test. blah blah blah";
  var text2 = "this is other text. blah blah blah";
  //dmp.Diff_Timeout = 1; // set 0 for no timeout

  var ms_start = (new Date()).getTime();
  var d = dmp.diff_main(text1, text2);
  var ms_end = (new Date()).getTime();

  if (true) {
  if (false) {
    dmp.Diff_EditCost = 4;
  //var ds = dmp.diff_prettyHtml(d);
  //console.log(ds + '<br/>Time: ' + (ms_end - ms_start) / 1000 + 's');

output: [ [ 0, 'this is ' ], [ -1, 'some' ], [ 1, 'other' ], [ 0, ' te' ], [ -1, 's' ], [ 1, 'x' ], [ 0, 't. blah blah blah' ] ]

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free