Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does nodejs have a working diff library or algorithm? [closed]

I'm looking for a javascript diff algorithm implementation or library, which has been tested on and works with arbitrary utf8 text files.

All of the ones I found so far (say for example, http://ejohn.org/projects/javascript-diff-algorithm/) fail on corner cases

(Try using a file which contains the string '__proto__' in my example library.)

like image 955
blueberryfields Avatar asked Sep 09 '25 19:09

blueberryfields


2 Answers

Maybe this will help you — jsdiff

like image 177
anton_byrna Avatar answered Sep 12 '25 10:09

anton_byrna


I'm a fan of google diff match patch. You can try out an example here.

There are different cleanup option to tweak the level of commonality between the diffs. I don't like the semantic cleanup option as I find it's too aggressive, but the efficiency cleanup with a value of 10 works well for me.

like image 27
TimE Avatar answered Sep 12 '25 08:09

TimE