typecov
Version:
Track type coverage in TypeScript projects to ensure type safety
43 lines • 1.61 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
function formatShortDescription({ coverageDiffPerc, headTypeCoveragePerc, newUntypedSymbols, baseReportExisted, }) {
if (!baseReportExisted) {
return "New type coverage report!";
}
const change = renderSign(coverageDiffPerc) + perc(coverageDiffPerc);
const total = perc(headTypeCoveragePerc);
if (coverageDiffPerc === 0) {
return `No changes detected. Total: ${total}`;
}
return `Change: ${change} Total: ${total} New untyped symbols: ${newUntypedSymbols}`;
}
exports.formatShortDescription = formatShortDescription;
function floor(n, precision = 2) {
const factor = Math.pow(10, precision);
return Math.floor(n * factor) / factor;
}
exports.floor = floor;
function perc(n, precision = 2) {
// Round down when losing precision to err on the side of caution.
// E.g. 99.9999% is still less than 100% so should render as 99.99% instead.
return floor(n, precision).toFixed(precision) + "%";
}
exports.perc = perc;
function renderSign(value) {
if (value > 0) {
return "+";
}
else {
// we dont' render signs for negative (it's part of a number xD) or 0
return "";
}
}
exports.renderSign = renderSign;
function getDescriptionAboutThreshold(options, status) {
if (!options.atLeast) {
return "";
}
return `Minimum acceptable type coverage: ${perc(options.atLeast)} — ${status == "success" ? "✅" : "🔴"}`;
}
exports.getDescriptionAboutThreshold = getDescriptionAboutThreshold;
//# sourceMappingURL=formatters.js.map