Open
Description
While you can create a unified diff with createPatch
and then apply that to another string using applyPatch
, there doesn't seem to be a way to apply Change Objects.
I think this would be helpful to apply diffs to data where line-context is not sufficient to match the diff.
e.g., something like:
const str1 = 'Greetings,\nhello world'
const str2 = 'Greetings\nhello my friend'
const diffs = diffWords( str1, str2 )
const result = applyDiffs( 'hello world', diffs )
expect( result ).to.equal( 'hello my friend' )