MCPcopy
hub / github.com/jestjs/jest / getCommonAndChangedSubstrings

Function getCommonAndChangedSubstrings

packages/jest-matcher-utils/src/index.ts:257–273  ·  packages/jest-matcher-utils/src/index.ts::getCommonAndChangedSubstrings
(
  diffs: Array<Diff>,
  op: number,
  hasCommonDiff: boolean,
)

Source from the content-addressed store, hash-verified

255class="cm">// * include change substrings which have argument op
256class="cm">// with inverse highlight only if there is a common substring
257const getCommonAndChangedSubstrings = (
258 diffs: Array<Diff>,
259 op: number,
260 hasCommonDiff: boolean,
261): string =>
262 diffs.reduce(
263 (reduced: string, diff: Diff): string =>
264 reduced +
265 (diff[0] === DIFF_EQUAL
266 ? diff[1]
267 : diff[0] === op
268 ? hasCommonDiff
269 ? INVERTED_COLOR(diff[1])
270 : diff[1]
271 : class="st">''),
272 class="st">'',
273 );
274
275const isLineDiffable = (expected: unknown, received: unknown): boolean => {
276 const expectedType = getType(expected);

Callers 1

printDiffOrStringifyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected