jsdiff icon indicating copy to clipboard operation
jsdiff copied to clipboard

Feature Request: Apply to a change to a String

Open PlainviewData opened this issue 8 years ago • 2 comments

Maybe I'm not seeing it in the docs, but I think it would be nice to apply a Change Object, or an array of them, to a string to be able to create a changed string.

PlainviewData avatar Apr 23 '17 03:04 PlainviewData

+1 for this feature

subwaymatch avatar May 13 '17 19:05 subwaymatch

Makes sense, but figuring out how to adapt the logic in applyPatch is not entirely trivial. That logic assumes that the changes are a series of hunks with line numbers and local context (rather than literally the entire file content being included in the diff like it is with change objects) and that each change is to an entire line; these things aren't reliably true for change objects.

ExplodingCabbage avatar Dec 27 '23 13:12 ExplodingCabbage