robosats/frontend/src/utils/prettyNumbers.ts
2022-05-06 12:32:13 +02:00

12 lines
268 B
TypeScript

export const pn = (value?: number | null): string | undefined => {
if (value === null || value === undefined) {
return;
}
const parts = value.toString().split(".");
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return parts.join(".");
};