-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathformat.ts
More file actions
32 lines (30 loc) · 842 Bytes
/
format.ts
File metadata and controls
32 lines (30 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* Shared formatting utilities for release commands.
*
* Small helpers used by both `list.ts` and `view.ts` to format
* health/adoption metrics consistently.
*/
/**
* Format a percentage value with one decimal place, or "—" when absent.
*
* @example fmtPct(42.3) // "42.3%"
* @example fmtPct(null) // "—"
*/
export function fmtPct(value: number | null | undefined): string {
if (value === null || value === undefined) {
return "—";
}
return `${value.toFixed(1)}%`;
}
/**
* Format an integer count with thousands separators, or "—" when absent.
*
* @example fmtCount(52000) // "52,000"
* @example fmtCount(null) // "—"
*/
export function fmtCount(value: number | null | undefined): string {
if (value === null || value === undefined) {
return "—";
}
return value.toLocaleString("en-US");
}