MCPcopy Create free account
hub / github.com/nodejs/node / createTabularErrorsDisplay

Function createTabularErrorsDisplay

test/fixtures/snapshot/typescript.js:122832–122855  ·  view source on GitHub ↗
(filesInError, host)

Source from the content-addressed store, hash-verified

122830 }
122831 ts.getErrorSummaryText = getErrorSummaryText;
122832 function createTabularErrorsDisplay(filesInError, host) {
122833 var distinctFiles = filesInError.filter(function (value, index, self) { return index === self.findIndex(function (file) { return (file === null || file === void 0 ? void 0 : file.fileName) === (value === null || value === void 0 ? void 0 : value.fileName); }); });
122834 if (distinctFiles.length === 0)
122835 return "";
122836 var numberLength = function (num) { return Math.log(num) * Math.LOG10E + 1; };
122837 var fileToErrorCount = distinctFiles.map(function (file) { return [file, ts.countWhere(filesInError, function (fileInError) { return fileInError.fileName === file.fileName; })]; });
122838 var maxErrors = fileToErrorCount.reduce(function (acc, value) { return Math.max(acc, value[1] || 0); }, 0);
122839 var headerRow = ts.Diagnostics.Errors_Files.message;
122840 var leftColumnHeadingLength = headerRow.split(" ")[0].length;
122841 var leftPaddingGoal = Math.max(leftColumnHeadingLength, numberLength(maxErrors));
122842 var headerPadding = Math.max(numberLength(maxErrors) - leftColumnHeadingLength, 0);
122843 var tabularData = "";
122844 tabularData += " ".repeat(headerPadding) + headerRow + "\n";
122845 fileToErrorCount.forEach(function (row) {
122846 var file = row[0], errorCount = row[1];
122847 var errorCountDigitsLength = Math.log(errorCount) * Math.LOG10E + 1 | 0;
122848 var leftPadding = errorCountDigitsLength < leftPaddingGoal ?
122849 " ".repeat(leftPaddingGoal - errorCountDigitsLength)
122850 : "";
122851 var fileRef = prettyPathForFileError(file, host.getCurrentDirectory());
122852 tabularData += "".concat(leftPadding).concat(errorCount, " ").concat(fileRef, "\n");
122853 });
122854 return tabularData;
122855 }
122856 function isBuilderProgram(program) {
122857 return !!program.getState;
122858 }

Callers 1

getErrorSummaryTextFunction · 0.85

Calls 10

numberLengthFunction · 0.85
prettyPathForFileErrorFunction · 0.85
reduceMethod · 0.80
concatMethod · 0.80
filterMethod · 0.65
mapMethod · 0.65
forEachMethod · 0.65
maxMethod · 0.45
splitMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected