MCPcopy Index your code
hub / github.com/code-pushup/cli / pluralize

Function pluralize

packages/utils/src/lib/formatting.ts:24–40  ·  view source on GitHub ↗
(text: string, amount?: number)

Source from the content-addressed store, hash-verified

22}
23
24export function pluralize(text: string, amount?: number): string {
25 if (amount != null && Math.abs(amount) === 1) {
26 return text;
27 }
28
29 // best approximation of English pluralization "rules"
30 // https://www.grammarly.com/blog/grammar/spelling-plurals-with-s-es/
31
32 if (text.endsWith('y')) {
33 return `${text.slice(0, -1)}ies`;
34 }
35 const suffixes = ['s', 'sh', 'ch', 'x', 'z'];
36 if (suffixes.some(suffix => text.endsWith(suffix))) {
37 return `${text}es`;
38 }
39 return `${text}s`;
40}
41
42export function formatBytes(bytes: number, decimals = 2) {
43 const positiveBytes = Math.max(bytes, 0);

Callers 13

binding.tsFile · 0.90
logLcovRecordsFunction · 0.90
getNxCoveragePathsFunction · 0.90
getItemTypeFunction · 0.90
loadArtifactsFunction · 0.90
formatTargetFunction · 0.90
outdatedToDisplayValueFunction · 0.90
logSourceFilesFunction · 0.90
logReportFunction · 0.90
pluralizeTokenFunction · 0.70
summarizeDiffOutcomesFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected