@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
24 lines (22 loc) • 472 B
text/typescript
export const counterValueFormatter = ({
currency,
value,
shorten,
locale,
}: {
currency?: string;
value?: number;
shorten?: boolean;
locale: string;
}): string => {
if (!value) {
return "-";
}
return new Intl.NumberFormat(locale, {
style: currency ? "currency" : "decimal",
currency,
notation: shorten ? "compact" : "standard",
maximumFractionDigits: shorten ? 3 : 8,
}).format(value);
};
export default counterValueFormatter;