viruschidai / diff-json

A javascript object diff tool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Advantage over changeset?

trusktr opened this issue · comments

Is there an advantage of diff-json over changeset?

The main difference was for comparing array:

  • changeset compares array elements based on the index
  • diff-json can compares array elements based on a provided key

For example:

var a = [
  {id: 1, value: 1},
  {id: 2, value: 2}
]

var b = [
  {id: 2, value: 2},
  {id: 1, value: 1}
]

changeset generates two diffs, diff-json generates no diffs by using key id. This was when the time diff-json created, not sure how true it is now.