Skip to content

No function to apply diffs from diffChars, diffWords, etc. #95

Open
@sirbrillig

Description

@sirbrillig

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' )

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions