Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ import chalk from 'chalk'
const ERROR = chalk.bold.red
const SUCCESS = chalk.bold.green

const formatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD'
})

export const logError = (message: string) => {
console.error(ERROR(message))
process.exit(1)
Expand All @@ -18,7 +13,16 @@ export const logSuccess = (message: string) => {
}

export const format = (price: number) => {
return formatter.format(price)
const decimalPart = price.toString().split('.')[1]
// If the decimal part starts with 000, it's likely a meme coin
// and we want to show more decimal places to avoid showing 0.00
const isMemeCoin = decimalPart && decimalPart.slice(0, 3) === '000'

return new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
maximumFractionDigits: isMemeCoin ? 10 : 2
}).format(price)
}

export const formatFileName = (coinName: string, fileExt: string): string => {
Expand Down