Open Bartvds opened 10 years ago
For me, the litmus test is the diff of "foo" and "ffoo". :wink: And based on this, Neil Fraser’s diff-match-patch would be my favorite.
diff-match-patch
only needs two change objects. Whereas diff
and chardiff
produce essentially the same result, that comprises three change objects.
diff-match-patch
(NPM package):
[ [ 1, 'f' ],
[ 0, 'foo' ] ]
diff
:
[ { count: 1, value: 'f' },
{ count: 1,
added: true,
removed: undefined,
value: 'f' },
{ count: 2, value: 'oo' } ]
chardiff
:
[ { type: '=', value: 'f' },
{ type: '+', right: 'f' },
{ type: '=', value: 'oo' } ]
Would you be interested in a pull request?
Does slightly better with line-based content (still fragments individual characters, but less then current diff?)
https://npmjs.org/package/chardiff