3 ms·
JSON-Patch [1] can be helpful here. You can maintain a list of changes that need to be applied, such that they only touch the parts of the document that need to
by pkaeding 10y ago
JSON-Patch [1] can be helpful here. You can maintain a list of changes that need to be applied, such that they only touch the parts of the document that need to change (other changes to other parts can be interleaved). If necessary, you can include tests to assert that some value in the document is what you expect it should be, and the patch can be rejected if that test fails.
[1]: http://jsonpatch.com/ http://jsonpatch.com/
- coldtea 10y agoThat's if what's to be changed is a document (which is a big if). Things get ugly quickly for any more complicated scenario.
- pkaeding 10y agoYeah, that's true. JSON-patch won't help with all situations. It is still an under-utilized tool, IMO.
- amelius 10y agoI think it's strange that it doesn't efficiently handle patches of strings. By the way, I'm still looking for a 3-way merge algorithm for any datatype in Javascript.