mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com> Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> Co-authored-by: Matt Rubens <mrubens@users.noreply.github.com>
22 lines
469 B
TypeScript
22 lines
469 B
TypeScript
const formatter = new Intl.NumberFormat("en-US", {
|
|
style: "currency",
|
|
currency: "USD",
|
|
})
|
|
|
|
export const formatCurrency = (amount: number) => formatter.format(amount)
|
|
|
|
export const formatTokens = (tokens: number) => {
|
|
if (tokens < 1000) {
|
|
return tokens.toString()
|
|
}
|
|
|
|
if (tokens < 1000000) {
|
|
return `${(tokens / 1000).toFixed(1)}K`
|
|
}
|
|
|
|
if (tokens < 1000000000) {
|
|
return `${(tokens / 1000000).toFixed(1)}M`
|
|
}
|
|
|
|
return `${(tokens / 1000000000).toFixed(1)}B`
|
|
}
|