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

Export DiffContext, PatchContext, ReverseContext? #285

Open
schnerd opened this issue May 13, 2020 · 1 comment
Open

Export DiffContext, PatchContext, ReverseContext? #285

schnerd opened this issue May 13, 2020 · 1 comment

Comments

@schnerd
Copy link
Contributor

schnerd commented May 13, 2020

I wrote a jsondiffpatch plugin arrays-by-hash a few years ago that tracks changes to items in arrays using their objectHash instead of their index. When I wrote it I was naively importing a few things from the /src directory of jsondiffpatch:

var DiffContext = require('jsondiffpatch/src/contexts/diff').DiffContext;
var PatchContext = require('jsondiffpatch/src/contexts/patch').PatchContext;
var ReverseContext = require('jsondiffpatch/src/contexts/reverse').ReverseContext;
var lcs = require('jsondiffpatch/src/filters/lcs');

When the build process changed after version v0.2.5, the src directory is no longer present – this makes sense but also means that developers cannot get access these *Context objects when writing their plugins. The default array filters use these objects, so any developer who hopes to override this behavior is out of luck – someone in #254 also ran into this issue.

Can we export some of these modules as a part of the public API? Happy to submit a PR.

Alternatively the project could add arrays-by-hash like functionality natively, I see numerous users running into this #269, #254, #154, #167, and it's pretty much essential if you want reliable merge-like functionality where you apply multiple distinct patches to an object.

@AesSedai
Copy link

I opened a PR against your repo to resolve the issue: schnerd/jsondiffpatch-arrays-by-hash#2

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

2 participants