Package Exports
- disparity
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (disparity) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
disparity
Colorized string diff ideal for text/code that spans through multiple lines.
This is basically just a wrapper around diff and ansi-styles + line numbers and omitting lines that don't have changes and that wouldn't help user identify the diff "context".
We also replace some invisible chars to make it easier to understand what really changed from one file to another:
\r
becomes<CR>
\n
becomes<LF>
\t
becomes<tab>
Created mainly to be used by esformatter and other tools that might need to display a nice looking diff of source files.
API
var disparity = require('disparity');
chars(oldStr, newStr[, opts]):String
Diffs two blocks of text, comparing character by character and returns
a String
with ansi color codes.
var diff = disparity.chars(file1, file2);
console.log(diff);
Will return an empty string if oldStr === newStr
;
// default options
var opts = {
// how many lines to display before/after a line that contains diffs
context: 3,
// text displayed just before the diff
header: '\u001b[41mmremoved\u001b[49m \u001b[42madded\u001b[49m\n\n'
};
unified(oldStr, newStr[, filePathOld, filePathNew]):String
Returns ansi colorized unified diff.
var diff = disparity.unified(file1, file2);
console.log(diff);
Will return an empty string if oldStr === newStr
;
License
Released under the MIT license.