MCPcopy Create free account
hub / github.com/code-pushup/cli / formatValueChange

Function formatValueChange

packages/utils/src/lib/reports/utils.ts:131–145  ·  view source on GitHub ↗
({
  values,
  scores,
}: Pick<AuditDiff, 'values' | 'scores'>)

Source from the content-addressed store, hash-verified

129}
130
131export function formatValueChange({
132 values,
133 scores,
134}: Pick<AuditDiff, 'values' | 'scores'>): InlineText {
135 const marker = getDiffMarker(values.diff);
136 const percentage =
137 values.before === 0
138 ? values.diff > 0
139 ? Number.POSITIVE_INFINITY
140 : Number.NEGATIVE_INFINITY
141 : roundValue((values.diff / values.before) * 100);
142 // eslint-disable-next-line no-irregular-whitespace
143 const text = `${formatDiffNumber(percentage)} %`;
144 return colorByScoreDiff(`${marker} ${text}`, scores.diff);
145}
146
147export function calcDuration(start: number, stop?: number): number {
148 return Math.round((stop ?? performance.now()) - start);

Callers 2

createDiffAuditsSectionFunction · 0.85
utils.unit.test.tsFile · 0.85

Calls 4

getDiffMarkerFunction · 0.85
roundValueFunction · 0.85
formatDiffNumberFunction · 0.85
colorByScoreDiffFunction · 0.85

Tested by

no test coverage detected