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

Function joinAlignedDiffsExpand

packages/jest-diff/src/joinAlignedDiffs.ts:289–309  ·  view source on GitHub ↗
(
  diffs: Array<Diff>,
  options: DiffOptionsNormalized,
)

Source from the content-addressed store, hash-verified

287// Given array of aligned strings with inverse highlight formatting,
288// return joined lines with diff formatting.
289export const joinAlignedDiffsExpand = (
290 diffs: Array<Diff>,
291 options: DiffOptionsNormalized,
292): string =>
293 diffs
294 .map((diff: Diff, i: number, diffs: Array<Diff>): string => {
295 const line = diff[1];
296 const isFirstOrLast = i === 0 || i === diffs.length - 1;
297
298 switch (diff[0]) {
299 case DIFF_DELETE:
300 return printDeleteLine(line, isFirstOrLast, options);
301
302 case DIFF_INSERT:
303 return printInsertLine(line, isFirstOrLast, options);
304
305 default:
306 return printCommonLine(line, isFirstOrLast, options);
307 }
308 })
309 .join('\n');

Callers 2

printDiffLinesFunction · 0.90

Calls 3

printDeleteLineFunction · 0.85
printInsertLineFunction · 0.85
printCommonLineFunction · 0.85

Tested by

no test coverage detected