I'm trying to use deep-object-diff to compare different copies of https://github.com/mdn/browser-compat-data, which is a dataset describing the web platform itself. As such, it has a key called "hasOwnProperty" to describe that method. deep-object-diff uses code like obj.hasOwnProperty(key) a lot, and obj.hasOwnProperty will in this case be an object in the BCD data, not Object.prototype.hasOwnProperty.
This causes deep-object-diff to throw an exception, the first place being here.
|
return r.hasOwnProperty(key) ? acc : { ...acc, [key]: undefined }; |
Simplified a bit, here's a subset of the data:
{
"javascript": {
"builtins": {
"Object": {
"hasOwnProperty": {
"__compat": "an object with more stuff here"
}
}
}
}
}
Repro script showing the problem:
const { diff } = require("deep-object-diff");
diff({"hasOwnProperty": 1}, {"hasOwnProperty": 2});
This will throw "Uncaught TypeError: r.hasOwnProperty is not a function".
A possible fix for this would be to add a hasOwnProperty wrapper to https://github.com/mattphillips/deep-object-diff/blob/master/src/utils/index.js and always use that, but there may be other ways.
I'm trying to use deep-object-diff to compare different copies of https://github.com/mdn/browser-compat-data, which is a dataset describing the web platform itself. As such, it has a key called "hasOwnProperty" to describe that method. deep-object-diff uses code like
obj.hasOwnProperty(key)a lot, andobj.hasOwnPropertywill in this case be an object in the BCD data, notObject.prototype.hasOwnProperty.This causes deep-object-diff to throw an exception, the first place being here.
deep-object-diff/src/diff/index.js
Line 12 in 45549c8
Simplified a bit, here's a subset of the data:
{ "javascript": { "builtins": { "Object": { "hasOwnProperty": { "__compat": "an object with more stuff here" } } } } }Repro script showing the problem:
This will throw "Uncaught TypeError: r.hasOwnProperty is not a function".
A possible fix for this would be to add a
hasOwnPropertywrapper to https://github.com/mattphillips/deep-object-diff/blob/master/src/utils/index.js and always use that, but there may be other ways.