Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix to reset an unset trigger through insertedKey

  • Loading branch information...
commit 91be697116ce47c5a405f7055446298bfa70e77c 1 parent 139b1c0
@substack authored
Showing with 15 additions and 6 deletions.
  1. +11 −4 example/colors.js
  2. +4 −2 index.js
View
15 example/colors.js
@@ -1,12 +1,19 @@
-var diff = require('../')({ indent : 2, comma : 'first' });
+var diff = require('../')({ indent : 2 });
function qqq () {}
diff(
- { yy : 6, zz : 5, a : [1,2,3], fn : qqq },
{
- a : [ 1, 2, 3, [4], "z", /beep/, new Buffer(3) ],
+ yy : 6,
+ zz : 5,
+ a : [1,2,3],
+ fn : qqq,
+ c : { x : 7, z : 3 }
+ },
+ {
+ a : [ 1, 2, "z", /beep/, new Buffer(3) ],
fn : 8,
- b : [5,6,7]
+ b : [5,6,7],
+ c : { x : 8, y : 9 }
}
).pipe(process.stdout, { end : false });
View
6 index.js
@@ -120,7 +120,7 @@ function difflet (opts, prev, next) {
})
: []
;
-
+
this.before(function () {
if (inserted) set('inserted');
write(indent && commaFirst ? '{ ' : '{');
@@ -144,6 +144,7 @@ function difflet (opts, prev, next) {
this.post(function (child) {
if (child.isLast && deleted.length) {
if (insertedKey) unset('inserted');
+ insertedKey = false;
if (indent && commaFirst) {
write(indentx + '\n, ')
@@ -158,6 +159,7 @@ function difflet (opts, prev, next) {
else write(',');
}
if (insertedKey) unset('inserted');
+ insertedKey = false;
}
});
@@ -189,7 +191,7 @@ function difflet (opts, prev, next) {
write(indentx.slice(indent) + ' }');
}
else if (indent) {
- write(indentx + '\n}');
+ write('\n' + indentx.slice(indent) + '}');
}
else write('}');
});
Please sign in to comment.
Something went wrong with that request. Please try again.