Closed schnerd closed 7 years ago
makes sense! thank you for the contribution 👍
@benjamine awesome! when do you generally do new releases on npm?
I currently have the following code:
const diffPipe = jsonDiffPatch.processor.pipes.diff;
const patchPipe = jsonDiffPatch.processor.pipes.patch;
let filterIndex = findIndex(diffPipe.filters, {filterName: 'arrays'});
diffPipe.filters[filterIndex] = jsondiffpatchArraysByHash.diffFilter;
// Replace patch arrays filter with our custom patch filter
filterIndex = findIndex(patchPipe.filters, {filterName: 'arrays'});
patchPipe.filters[filterIndex] = jsondiffpatchArraysByHash.patchFilter;
// Replace patch arrays collect children filter with our custom patch filter
filterIndex = findIndex(patchPipe.filters, {filterName: 'arraysCollectChildren'});
patchPipe.filters[filterIndex] = jsondiffpatchArraysByHash.collectChildrenPatchFilter;
but hoping to simplify it to this after next jsondiffpatch publish.
jsonDiffPatch.processor.pipes.diff
.replace('arrays', jsondiffpatchArraysByHash.diffFilter);
jsonDiffPatch.processor.pipes.patch
.replace('arrays', jsondiffpatchArraysByHash.patchFilter)
.replace('arraysCollectChildren', jsondiffpatchArraysByHash.collectChildrenPatchFilter);
sure, pushed as 0.2.5 👍
btw, if you plan to open source that plugin would love to check it out and maybe add it on a section of 3rd party plugins on this project's README.
You're awesome, thank you!
Here's the plugin: https://github.com/schnerd/jsondiffpatch-arrays-by-hash
It's basically a fork of the array filters that stores the result of objectHash in the diff to better support "merges" when arrays have been reordered. Might help #167 #154 #91. Would love to hear your thoughts.
Still doing some final testing, but once i'm done I can either reply here or submit a PR with a link on the 3rd party plugins page in this repo.
Alright–done testing and updating documentation, and just published to npm. Feel free to check it out and link to it from the main jsondiffpatch docs if you'd like.
I'm creating a plugin (schnerd/jsondiffpatch-arrays-by-hash) and would love to have these pipe methods to manipulate the pipes array when adding my plugin.
replace(filterName, filter1, filter2, ...)
- Replace the specified filter with one ore more filtersremove(filterName)
- Remove the filter with the specified nameThoughts?