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

[question] is it possible to omit certain fields from the diff? #258

Open
vlamic opened this issue Nov 28, 2018 · 7 comments
Open

[question] is it possible to omit certain fields from the diff? #258

vlamic opened this issue Nov 28, 2018 · 7 comments

Comments

@vlamic
Copy link

vlamic commented Nov 28, 2018

First of all - thanks for your library - it rocks! ❤️

I have a question.
I know it's possible to use propertyFilter to exclude certain fields from participating in diff. However, these fields are still present in the resulting diff (applies for added elements). Is there an option to also exclude these field for these added elements?

Thanks!

@mebibou
Copy link

mebibou commented Jun 15, 2021

+1 for this feature, it is nice to be able to ignore properties but since they are still displayed it seems as if both left and right objects have the same value which is incorrect.
Having a displayFilter would be nice?

Note: right now I am using lodash omit to exclude those properties but this works out of the box only on top properties so not ideal

@prasanmgc
Copy link

Hi @vlamic,

Could you please explain how you have implemented the propertyFilter to exclude certain fields? your help much appreciated?

Thanks

@mebibou
Copy link

mebibou commented Feb 18, 2022

@prasanmgc you just need to do propertyFilter: name => !['field1', 'field2'].includes(name) and field1/field2 won't be compared

@prasanmgc
Copy link

prasanmgc commented Feb 18, 2022

Thanks a lot @mebibou. It worked. you saved my time.

@prasanmgc
Copy link

prasanmgc commented Feb 19, 2022

@mebibou Just a quick question. Is it possible to reference the ignored fields from a class variable? I am getting an error when i use the below.
propertyFilter: function (name: string) { !this.ignoredFields.includes(name); }

TypeError: Cannot read property 'ignoredFields' of undefined

@mebibou
Copy link

mebibou commented Feb 19, 2022

@prasanmgc I suggest you read first what this refers to in JavaScript to understand the error. But you should do this instead

var ignoredFields = [];
create({
  propertyFilter(name: string) { return !ignoredFields.includes(name); }
});

@gnyani
Copy link

gnyani commented Jan 20, 2023

@mebibou @prasanmgc property filter doesn't remove the fields from the nested objects, did it work for you for nested objects too?

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

4 participants