mattphillips / deep-object-diff

Deep diffs two objects, including nested structures of arrays and objects, and returns the difference. ❄️
https://www.npmjs.com/package/deep-object-diff
MIT License
1.05k stars 89 forks source link

Problem with dates comparison #5

Closed vbgm closed 7 years ago

vbgm commented 7 years ago

Once an object has dates, they seem to not compare, just get ignored.

  const oldItem = { someDate: new Date() };
  console.log('oldItem', oldItem);

  const newItem = { someDate: moment('2017-01-01').toDate() };
  console.log('newItem', newItem);

  const diffDetails = detailedDiff(oldItem, newItem);
  console.log('diffDetails', diffDetails);

outputs to:

oldItem { someDate: Tue Feb 14 2017 13:22:36 GMT+0100 (CET) }
newItem { someDate: Sun Jan 01 2017 00:00:00 GMT+0100 (CET) }
diffDetails { added: {}, deleted: {}, updated: {} }
mattphillips commented 7 years ago

@vblagomir hey thanks for raising the issue! I've just published v1.0.1 that adds support for Date comparisons let me know if that fixes your issue 😄

vbgm commented 7 years ago

wow @mattphillips that was fast! 👍 Let me check it!

vbgm commented 7 years ago

Thank you, the issue is fixed! 👍