Reorganize repo structure and standards references
This commit is contained in:
1 parent
3cb93a81be
commit
be2054274d
5885 files changed
+2588
-195
No files matched your search
@@ -0,0 +1,20 @@
|
||||
// Locale-aware currency formatter. Currency code is required (ISO-4217) so
|
||||
// callers cannot accidentally render an amount without the symbol — matches
|
||||
// billing/invoice surfaces that always know their currency.
|
||||
|
||||
import { getCachedFormatter } from "./cache.js";
|
||||
|
||||
export type FormatCurrencyOptions = {
|
||||
locale: string;
|
||||
currency: string;
|
||||
minimumFractionDigits?: number;
|
||||
maximumFractionDigits?: number;
|
||||
currencyDisplay?: Intl.NumberFormatOptions["currencyDisplay"];
|
||||
};
|
||||
|
||||
const currencyFormatters = new Map<string, Intl.NumberFormat>();
|
||||
|
||||
export function formatCurrency(value: number, options: FormatCurrencyOptions): string {
|
||||
const { locale, currency, ...rest } = options;
|
||||
return getCachedFormatter(currencyFormatters, locale, { style: "currency", currency, ...rest }, (formatterLocale, formatterOptions) => new Intl.NumberFormat(formatterLocale, formatterOptions)).format(value);
|
||||
}
|
||||
Reference in new issue
Block a user