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

Add support for diff-ing Symbols #135

Open ioxua opened 6 years ago

ioxua commented 6 years ago

Running the code:

const { DeepDiff } = require("deep-diff")
const foo = {
  [Symbol.iterator]: "Let's pretend this is an iterator"
}
const bar = {
  bar: "Random prop"
}

console.log(DeepDiff(foo, bar))

Results in:

[ DiffNew { kind: 'N', path: [ 'bar' ], rhs: 'Random prop' } ]

Instead of:

[ DiffNew { kind: 'N', path: [ 'bar' ], rhs: 'Random prop' },
  DiffDeleted { kind: 'D', path: [ Symbol.iterator ], lhs: 'Let's pretend this is an iterator' },]

That would be preferable. There is any reason it happens this way?