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

Does not detect differences in order #42

Closed giorgio79 closed 5 years ago

giorgio79 commented 5 years ago

When diffing two objects where I would like the order of keys to matter:


const { diff, addedDiff, deletedDiff, detailedDiff, updatedDiff } = require("deep-object-diff");

const right = {
1: "Tom",
2: "reads",
3: ",",
4: "novels"
};

const wrong = {
1: "Tom",
2: "reads",
3: "novels",
4: ","
};

console.log(detailedDiff(right, wrong)); 

And the result is:

Object {added: , deleted: , updated: }

mattphillips commented 5 years ago

Seems to working fine check out: https://runkit.com/embed/uy9n61eue7s3

It logs:

added: Object {}
deleted: Object {}
updated: Object {3: "novels", 4: ","}
giorgio79 commented 5 years ago

Right! Thanks and sry! :) I did not click the arrow to expand the result:

image

image