MCPcopy Index your code
hub / github.com/nodejs/node / getSimpleDiff

Function getSimpleDiff

lib/internal/assert/assertion_error.js:155–175  ·  view source on GitHub ↗
(originalActual, actual, originalExpected, expected)

Source from the content-addressed store, hash-verified

153}
154
155function getSimpleDiff(originalActual, actual, originalExpected, expected) {
156 let stringsLen = actual.length + expected.length;
157 // Accounting for the quotes wrapping strings
158 if (typeof originalActual === 'string') {
159 stringsLen -= 2;
160 }
161 if (typeof originalExpected === 'string') {
162 stringsLen -= 2;
163 }
164 if (stringsLen <= kMaxShortStringLength && (originalActual !== 0 || originalExpected !== 0)) {
165 return { message: `${actual} !== ${expected}`, header: '' };
166 }
167
168 const isStringComparison = typeof originalActual === 'string' && typeof originalExpected === 'string';
169 // colored myers diff
170 if (isStringComparison && colors.hasColors) {
171 return getColoredMyersDiff(actual, expected);
172 }
173
174 return getStackedDiff(actual, expected);
175}
176
177function isSimpleDiff(actual, inspectedActual, expected, inspectedExpected) {
178 if (inspectedActual.length > 1 || inspectedExpected.length > 1) {

Callers 1

createErrDiffFunction · 0.85

Calls 2

getColoredMyersDiffFunction · 0.85
getStackedDiffFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…