17 lines
570 B
TypeScript
17 lines
570 B
TypeScript
export function fmtNumber(value: number | null | undefined): string {
|
|
if (typeof value === "number") return value.toLocaleString();
|
|
if (value === null || value === undefined) return "";
|
|
return String(value);
|
|
}
|
|
|
|
export function indentPx(indNm: string | undefined): number {
|
|
if (!indNm) return 0;
|
|
const spaces = indNm.length - indNm.trimStart().length;
|
|
return (spaces / 4) * 16;
|
|
}
|
|
|
|
export function calcDiffPercent(diff: number, baseline: number): string {
|
|
if (baseline === 0) return "-";
|
|
return `${Math.round((diff / baseline) * 100)}%`;
|
|
}
|