Skip to content

Diff of two equal objects is not empty #32

Description

@EyalAr
jiff.diff({
  "a": {
    "b": {
      "c": [ ["a"], ["b"], ["c"] ]
    }
  }
}, {
  "a": {
    "b": {
      "c": [ ["a"], ["b"], ["c"] ]
    }
  }
});

Produces the following patch:

[ { op: 'add',
    path: '/a/b/c/0',
    value: [ 'a' ],
    context: undefined },
  { op: 'add',
    path: '/a/b/c/1',
    value: [ 'b' ],
    context: undefined },
  { op: 'add',
    path: '/a/b/c/2',
    value: [ 'c' ],
    context: undefined },
  { op: 'test',
    path: '/a/b/c/3',
    value: [ 'a' ],
    context: undefined },
  { op: 'remove', path: '/a/b/c/3', context: undefined },
  { op: 'test',
    path: '/a/b/c/3',
    value: [ 'b' ],
    context: undefined },
  { op: 'remove', path: '/a/b/c/3', context: undefined },
  { op: 'test',
    path: '/a/b/c/3',
    value: [ 'c' ],
    context: undefined },
  { op: 'remove', path: '/a/b/c/3', context: undefined } ]

Which is correct, in the sense that applying the patch will yield the correct result; but not efficient, as the patch could simply be empty.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions