Skip to content

Added support for comparing content of nested arrays #18

Merged
merged 2 commits into from Jan 2, 2016

4 participants

@benkitzelman

When comparing two objects with nested arrays, difflet fails to detail differences if the comparison objects array is empty.. ie:

  var subjectA = {
    levelOne: {
      levelTwo: {
        array: ['a', 'b', 3]
      }
    }
  };

  var subjectB = {
    levelOne: {
      levelTwo: {
        array: []
      }
    }
  };

diff.compare(subjectA, subjectB); // No diffs reported

This pull requests lists the missing elements if any elements are missing from the source, or comparison object's arrays

@benkitzelman

Is it possible to merge this yet? I would prefer to use your repo rather than my forked copy

@markstos
markstos commented Nov 5, 2014

The patch looks good me. Thanks for the bug fix!

I can't speak for the maintainer, but it's possible the pull request would be more likely to be merged if it was updated to remove all the whitespace updates. All the whitespace changes make it more difficult to pick out the actual important changes in the patch.

@substack
Owner

whitespace thrashing just causes merge conflict grief :/

@benkitzelman

Oops - my bad - sorry for leaving it this long to fix - shld be ok now.

@adrianheine adrianheine commented on an outdated diff Apr 24, 2015
test/object_tests.js
+ array: ['a']
+ }
+ }
+ };
+
+ var subjectB = {
+ levelOne: {
+ levelTwo: {
+ array: ['a', 'b', 3]
+ }
+ }
+ };
+
+ var d = diff.compare(subjectA, subjectB);
+ t.equal(d, "{\"levelOne\":{\"levelTwo\":{\"array\":[\"a\",\u001b[32m\u001b[1m\"b\"\u001b[0m,\u001b[32m\u001b[1m3\u001b[0m]}}}");
+});
@adrianheine
adrianheine added a note Apr 24, 2015

Missing newline

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@substack substack merged commit 4529c33 into substack:master Jan 2, 2016

1 check passed

Details continuous-integration/travis-ci/pr The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.