jsondiffpatch
jsondiffpatch copied to clipboard
Ignore functions instead of throwing error?
I understand that jsondiffpatch doesn't support diffing objects that have functions, I'm wondering if there is a way to simply ignore those functions instead of throwing error?
I tried using propertyFilter option like below but didn't help
propertyFilter: function (name, context) {
return typeof context.left !== 'function' && typeof context.right !== 'function'
}
Maybe we can filter the objects before calling diff but that extra CPU cost will be too much for us.
Any ideas? I'm open to raise a PR to that.
I realize this is old but in case someone stumbles this issue:
Your property filter would need to look like this.
propertyFilter: function (name, context) {
return typeof context.left[name] !== 'function' && typeof context.right[name] !== 'function'
}
context.left and context.right aren't the objects that are compared but rather their parents.