jsondiffpatch icon indicating copy to clipboard operation
jsondiffpatch copied to clipboard

Ignore functions instead of throwing error?

Open ipip2005 opened this issue 4 years ago • 1 comments

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.

ipip2005 avatar Mar 18 '20 18:03 ipip2005

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.

schwarzeszeux avatar Aug 23 '23 10:08 schwarzeszeux