-
Notifications
You must be signed in to change notification settings - Fork 500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented diffJson #28
Conversation
It takes two objects, serializes them as canonical JSON, then does a line-based diff that ignores differences in trailing commas. See discussion here: mochajs/mocha#1182
Bump... However, it would be great if it accepted an already stringified JSON as well. |
@rooftopsparrow There, that was easy enough :) In that case it's the caller's duty to stringify the arguments with the same indentation level -- and to canonicalize the objects before stringifying them. |
Fabulous! Works like a charm. |
|
||
var canonicalizedObj; | ||
|
||
if ('[object Array]' == {}.toString.call(obj)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The toString
method should be cached. Using the object literal adds a bit of overhead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point -- fixed.
This generally looks pretty good. A few minor questions and generally wondering if those questions should have comments in the code explaining them but outside of that I'd like to get this into master. (BTW the travis environment failure should hopefully be fixed in master) |
…bject each time it's used.
If my explanations are good enough, we can add them as comments in the code :) |
…ow (rather than an infinite loop).
…ject can be substituted when a circular reference is detected.
I've fixed the merge conflicts and got this in. Thanks for writing this! |
Released in 1.2.0 |
It takes two objects, serializes them as canonical JSON, then does a line-based diff that ignores differences in trailing commas.
See discussion here: mochajs/mocha#1182