Skip to content

Commit

Permalink
Modify node_example.js to support showing added/deleted spaces (#479)
Browse files Browse the repository at this point in the history
  • Loading branch information
ExplodingCabbage authored Jan 26, 2024
1 parent 533893d commit b5d1cfa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,10 @@ const diff = Diff.diffChars(one, other);
diff.forEach((part) => {
// green for additions, red for deletions
// grey for common parts
const color = part.added ? 'green' :
part.removed ? 'red' : 'grey';
process.stderr.write(part.value[color]);
let text = part.added ? part.value.bgGreen :
part.removed ? part.value.bgRed :
part.value;
process.stderr.write(text);
});
console.log();
Expand Down
8 changes: 4 additions & 4 deletions examples/node_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ let diff = Diff.diffChars(one, other);

diff.forEach(function(part) {
// green for additions, red for deletions
// grey for common parts
let color = part.added ? 'green' :
part.removed ? 'red' : 'grey';
process.stderr.write(part.value[color]);
let text = part.added ? part.value.bgGreen :
part.removed ? part.value.bgRed :
part.value;
process.stderr.write(text);
});

console.log();

0 comments on commit b5d1cfa

Please sign in to comment.