From 9bdb95c9e34cef640534e5e5a1e2225a80442000 Mon Sep 17 00:00:00 2001 From: HelenHuang <LinHuang@pollex.com.tw> Date: 星期四, 09 六月 2022 15:48:15 +0800 Subject: [PATCH] TODO#139894 [ footer -最下方說明與保經代合作 ] 文案修改 --- PAMapp/node_modules/jest-diff/build/diffLines.js | 86 ++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 80 insertions(+), 6 deletions(-) diff --git a/PAMapp/node_modules/jest-diff/build/diffLines.js b/PAMapp/node_modules/jest-diff/build/diffLines.js index f0e4be1..89e7aae 100644 --- a/PAMapp/node_modules/jest-diff/build/diffLines.js +++ b/PAMapp/node_modules/jest-diff/build/diffLines.js @@ -3,18 +3,19 @@ Object.defineProperty(exports, '__esModule', { value: true }); -exports.diffLinesRaw = +exports.printDiffLines = exports.diffLinesUnified2 = exports.diffLinesUnified = + exports.diffLinesRaw = void 0; var _diffSequences = _interopRequireDefault(require('diff-sequences')); var _cleanupSemantic = require('./cleanupSemantic'); -var _normalizeDiffOptions = require('./normalizeDiffOptions'); +var _joinAlignedDiffs = require('./joinAlignedDiffs'); -var _printDiffs = require('./printDiffs'); +var _normalizeDiffOptions = require('./normalizeDiffOptions'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : {default: obj}; @@ -26,10 +27,83 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ -const isEmptyString = lines => lines.length === 1 && lines[0].length === 0; // Compare two arrays of strings line-by-line. Format as comparison lines. +const isEmptyString = lines => lines.length === 1 && lines[0].length === 0; + +const countChanges = diffs => { + let a = 0; + let b = 0; + diffs.forEach(diff => { + switch (diff[0]) { + case _cleanupSemantic.DIFF_DELETE: + a += 1; + break; + + case _cleanupSemantic.DIFF_INSERT: + b += 1; + break; + } + }); + return { + a, + b + }; +}; + +const printAnnotation = ( + { + aAnnotation, + aColor, + aIndicator, + bAnnotation, + bColor, + bIndicator, + includeChangeCounts, + omitAnnotationLines + }, + changeCounts +) => { + if (omitAnnotationLines) { + return ''; + } + + let aRest = ''; + let bRest = ''; + + if (includeChangeCounts) { + const aCount = String(changeCounts.a); + const bCount = String(changeCounts.b); // Padding right aligns the ends of the annotations. + + const baAnnotationLengthDiff = bAnnotation.length - aAnnotation.length; + const aAnnotationPadding = ' '.repeat(Math.max(0, baAnnotationLengthDiff)); + const bAnnotationPadding = ' '.repeat(Math.max(0, -baAnnotationLengthDiff)); // Padding left aligns the ends of the counts. + + const baCountLengthDiff = bCount.length - aCount.length; + const aCountPadding = ' '.repeat(Math.max(0, baCountLengthDiff)); + const bCountPadding = ' '.repeat(Math.max(0, -baCountLengthDiff)); + aRest = + aAnnotationPadding + ' ' + aIndicator + ' ' + aCountPadding + aCount; + bRest = + bAnnotationPadding + ' ' + bIndicator + ' ' + bCountPadding + bCount; + } + + return ( + aColor(aIndicator + ' ' + aAnnotation + aRest) + + '\n' + + bColor(bIndicator + ' ' + bAnnotation + bRest) + + '\n\n' + ); +}; + +const printDiffLines = (diffs, options) => + printAnnotation(options, countChanges(diffs)) + + (options.expand + ? (0, _joinAlignedDiffs.joinAlignedDiffsExpand)(diffs, options) + : (0, _joinAlignedDiffs.joinAlignedDiffsNoExpand)(diffs, options)); // Compare two arrays of strings line-by-line. Format as comparison lines. + +exports.printDiffLines = printDiffLines; const diffLinesUnified = (aLines, bLines, options) => - (0, _printDiffs.printDiffLines)( + printDiffLines( diffLinesRaw( isEmptyString(aLines) ? [] : aLines, isEmptyString(bLines) ? [] : bLines @@ -88,7 +162,7 @@ bIndex += 1; } }); - return (0, _printDiffs.printDiffLines)( + return printDiffLines( diffs, (0, _normalizeDiffOptions.normalizeDiffOptions)(options) ); -- Gitblit v1.8.0