Bartvds / unfunk-diff

Object & String diff formatter for all displays
MIT License
2 stars 1 forks source link

Evaluate 'chardiff' module as replacement for 'dif' #1

Open Bartvds opened 10 years ago

Bartvds commented 10 years ago

Does slightly better with line-based content (still fragments individual characters, but less then current diff?)

https://npmjs.org/package/chardiff

alexbepple commented 9 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' } ]
alexbepple commented 9 years ago

Would you be interested in a pull request?