Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

comment diffs for objects

  • Loading branch information...
commit 85b53f42031c0668df76a07d751307378190410a 1 parent 16e91e6
@substack authored
Showing with 17 additions and 12 deletions.
  1. +17 −12 index.js
View
29 index.js
@@ -117,14 +117,29 @@ function difflet (opts, prev, next) {
});
this.post(function (child) {
+ if (!child.isLast && !(indent && commaFirst)) {
+ write(',');
+ }
+
+ var prev = prevNode && prevNode[child.key];
+ if (indent && opts.diff && child.node !== prev
+ && (typeof child.node !== 'object' || typeof prev !== 'object')
+ ) {
+ set('comment');
+ write(' // != ');
+ traverse(prev).forEach(function (x) {
+ plainStringify.call(this, x, { indent : 0 });
+ });
+ unset('comment');
+ }
+
if (!child.isLast) {
if (indent && commaFirst) {
write('\n' + indentx + ', ');
}
else if (indent) {
- write(',\n' + indentx);
+ write('\n' + indentx);
}
- else write(',');
}
});
@@ -221,16 +236,6 @@ function difflet (opts, prev, next) {
if (insertedKey) unset('inserted');
insertedKey = false;
}
-
- var prev = prevNode && prevNode[child.key];
- if (opts.diff && child.node !== prev
- && (typeof child.node !== 'object' || typeof prev !== 'object')
- ) {
- set('comment');
- write(' // != ');
- plainStringify(prev, { indent : 0 });
- unset('comment');
- }
});
this.after(function () {
Please sign in to comment.
Something went wrong with that request. Please try again.