Spaces:
Sleeping
Sleeping
Download frontend/src/lib/utils.ts from JacellJamble/genesis: direct link, hf CLI and curl.
- Browser
- Download file 810 Bytes
-
https://huggingface.co/spaces/JacellJamble/genesis/resolve/main/frontend/src/lib/utils.ts
- Command line
-
hf download hf://spaces/JacellJamble/genesis/frontend/src/lib/utils.ts
-
curl -L -o utils.ts https://huggingface.co/spaces/JacellJamble/genesis/resolve/main/frontend/src/lib/utils.ts
810 Bytes
| import { type ClassValue, clsx } from "clsx"; | |
| import { twMerge } from "tailwind-merge"; | |
| export function cn(...inputs: ClassValue[]) { | |
| return twMerge(clsx(inputs)); | |
| } | |
| export function formatCurrency(value: any): string { | |
| if (value === undefined || value === null || isNaN(Number(value))) return "$0"; | |
| const num = Number(value); | |
| if (num >= 1_000_000) return `$${(num / 1_000_000).toFixed(1)}M`; | |
| if (num >= 1_000) return `$${(num / 1_000).toFixed(1)}K`; | |
| return `$${num.toFixed(0)}`; | |
| } | |
| export function formatNumber(value: any): string { | |
| if (value === undefined || value === null || isNaN(Number(value))) return "0"; | |
| const num = Number(value); | |
| if (num >= 1_000_000) return `${(num / 1_000_000).toFixed(1)}M`; | |
| if (num >= 1_000) return `${(num / 1_000).toFixed(1)}K`; | |
| return num.toString(); | |
| } | |