Skip to content

Commit

Permalink
refactor: simlify formatNumber
Browse files Browse the repository at this point in the history
  • Loading branch information
atrincas committed Jan 17, 2025
1 parent 5cb01d1 commit ebdb0aa
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions client/src/lib/format.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ export const formatNumber = (
value: number,
options: Intl.NumberFormatOptions = {},
) => {
const formatted = Intl.NumberFormat("en-US", {
style: "decimal",
maximumFractionDigits: 2,
...options,
}).format(value);

// Removes trailing ".00" if present
return formatted.replace(/\.00$/, "");
return (
Intl.NumberFormat("en-US", {
style: "decimal",
maximumFractionDigits: 2,
...options,
})
.format(value)
// Removes trailing ".00" if present
.replace(/\.00$/, "")
);
};

/**
Expand Down

0 comments on commit ebdb0aa

Please sign in to comment.