Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Added support for comparing content of nested arrays #18

Merged
merged 2 commits into from Jan 2, 2016

Conversation

Projects
None yet
4 participants
Contributor

benkitzelman commented Nov 21, 2013

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

Contributor

benkitzelman commented Oct 28, 2014

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

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.

Owner

substack commented Feb 19, 2015

whitespace thrashing just causes merge conflict grief :/

Contributor

benkitzelman commented Feb 20, 2015

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]}}}");
+});

@substack substack merged commit 4529c33 into substack:master Jan 2, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment