mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-05 16:04:43 +00:00
17 lines
455 B
TypeScript
17 lines
455 B
TypeScript
export function formatContextPercentage(value: number, locale?: string): string {
|
|
return new Intl.NumberFormat(locale, {
|
|
style: "percent",
|
|
maximumFractionDigits: 0,
|
|
}).format(value / 100);
|
|
}
|
|
|
|
export function formatTokenCount(value: number): string {
|
|
if (value >= 1_000_000) {
|
|
return `${Math.round(value / 1_000_000)}m`;
|
|
}
|
|
if (value >= 1_000) {
|
|
return `${Math.round(value / 1_000)}k`;
|
|
}
|
|
return Math.round(value).toString();
|
|
}
|