flitbit / diff

Javascript utility for calculating deep difference, capturing changes, and applying changes across objects; for nodejs and the browser.
MIT License
2.99k stars 213 forks source link

Feature request: report differences in prototype #112

Open cpcallen opened 7 years ago

cpcallen commented 7 years ago

These comparisons should all report some difference, but in fact do not:

diff({}, Object.create(null))  // === undefined

diff({}, Object.create({}))  // === undefined

var F = function(){};
diff({}, new F);  // === undefined

(I'm pleased to see that you do correctly return a non-empty diff for diff([], Object.create(Array.prototype)), though.)

For most objects it would be reasonable to report different prototypes using __proto__ notation, but for objects created using Object.create(null) or which have had an Object.defineProperty(o, '__proto__') done to them some other notation will be necessary.