Skip to content

Commit

Permalink
Merge pull request #413 from 00labs/number-util
Browse files Browse the repository at this point in the history
show 0 if number is 0
  • Loading branch information
shan-57blocks authored Jan 9, 2025
2 parents 41d8857 + 1eae683 commit 0eca8cf
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/huma-shared/src/utils/number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export const formatMoneyFixed = (
return num
}

toFixed = Number(num) === 0 ? 0 : toFixed

const numCast = Number(num)
const moneyFormatter = new Intl.NumberFormat('en-US', {
style: 'currency',
Expand Down Expand Up @@ -77,6 +79,8 @@ export const formatNumberFixed = (
return num
}

toFixed = Number(num) === 0 ? 0 : toFixed

const numberFormatter = new Intl.NumberFormat('en-US', {
maximumFractionDigits: toFixed,
minimumFractionDigits: toFixed,
Expand Down

0 comments on commit 0eca8cf

Please sign in to comment.