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 constructor name #109

Open alexanderbird opened 7 years ago

alexanderbird commented 7 years ago

It would be nice to have a new diff type indicator for mismatched constructors.

kind: 'C' path, is set as they would be for 'E' differences lhs is the value of the lhs item's constructor.name property rhs as with lhs index and item are unused

Example:

function Something(value) { this.value = value; }

var lhs = new Something('foo');
var rhs = { value: 'foo' };

Diffing the two would produce:

[{ kind: 'C',
    path: [  ],
    lhs: 'Something',
    rhs: 'Object' }]