MCPcopy
hub / github.com/amark/gun / errorDiff

Function errorDiff

test/mocha.js:2013–2025  ·  view source on GitHub ↗

* Return a character diff for `err`. * * @api private * @param {Error} err * @param {string} type * @param {boolean} escape * @return {string}

(err, type, escape)

Source from the content-addressed store, hash-verified

2011 * @return {string}
2012 */
2013function errorDiff(err, type, escape) {
2014 var actual = escape ? escapeInvisibles(err.actual) : err.actual;
2015 var expected = escape ? escapeInvisibles(err.expected) : err.expected;
2016 return diff['diff' + type](actual, expected).map(function(str) {
2017 if (str.added) {
2018 return colorLines('diff added', str.value);
2019 }
2020 if (str.removed) {
2021 return colorLines('diff removed', str.value);
2022 }
2023 return str.value;
2024 }).join('');
2025}
2026
2027/**
2028 * Returns a string with all invisible characters in plain text

Callers 1

inlineDiffFunction · 0.85

Calls 2

escapeInvisiblesFunction · 0.85
colorLinesFunction · 0.85

Tested by

no test coverage detected