unsloth/studio/frontend/src/lib/utils.ts
2026-02-04 13:28:39 +01:00

19 lines
470 B
TypeScript

import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]): string {
return twMerge(clsx(inputs));
}
export function formatCompact(n: number): string {
if (n >= 1_000_000_000) {
return `${(n / 1_000_000_000).toFixed(1)}B`;
}
if (n >= 1_000_000) {
return `${(n / 1_000_000).toFixed(1)}M`;
}
if (n >= 1_000) {
return `${(n / 1_000).toFixed(1)}K`;
}
return String(n);
}