Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Summation of Patches #143

Closed
suni-masuno opened this issue Jan 10, 2017 · 2 comments
Closed

Summation of Patches #143

suni-masuno opened this issue Jan 10, 2017 · 2 comments

Comments

@suni-masuno
Copy link

suni-masuno commented Jan 10, 2017

Is it possible, or reasonable, to take an array of patches and sum them into a final set of patches without an original document?

example...

[
{ "op": "add", "path": "/a/b/c", "value": 1},
{ "op": "replace", "path": "/a/b/c", "value": 12 },
{ "op": "replace", "path": "/a/b/c", "value": 123 },
{ "op": "replace", "path": "/a/b/c", "value": 1234 },
{ "op": "move", "from": "/a/b/c", "path": "/a/b/d" },
{ "op": "replace", "path": "/a/b/d", "value": 12345 },
]

and sum it to the actual final modification

[
{ "op": "add", "path": "/a/b/d", "value": 12345 },
]

Would this be a feature request?
NOTE: I could apply then compare to recreate this, but I'm interested in doing it without an original.

@tomalec
Copy link
Collaborator

tomalec commented May 15, 2017

That's a really great idea, we already faced similar concerns many times. But in favor of Unix philosophy, I'd rather see it as separate tool like "JSON-Patch compresor"/"optimizer", so you could do:

let compressedPatch = jsonpatch.compress(patch, tree);
jsonpatch.apply(tree, compressedPatch);

This compression could take an optional argument tree as a context optimize even more, but probably in more expensive manner.

//cc @alshakero

@alshakero
Copy link
Collaborator

I agree with the linux way too. I'll close this as out of scope.


Feel free to check #204 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants