@dnb/eufemia
Version:
DNB Eufemia Design System UI Library
37 lines • 1.05 kB
JavaScript
import { formatToParts, alignCurrencySymbol } from "./formatNumberCore.js";
import { getFallbackCurrencyDisplay, CURRENCY } from "./currencyDisplay.js";
export function getDecimalSeparator(locale = null) {
const separator = formatToParts({
number: 1.1,
locale
}).find(({
type
}) => type === 'decimal')?.value || ',';
return separator;
}
export function getThousandsSeparator(locale = null) {
return formatToParts({
number: 1000,
locale
}).find(({
type
}) => type === 'group')?.value || ' ';
}
export function getCurrencySymbol(locale = null, currency = null, display = null, number = 2) {
if (!currency || currency === true) {
currency = CURRENCY;
}
const currencyDisplay = getFallbackCurrencyDisplay(locale, display);
return alignCurrencySymbol(formatToParts({
number,
locale,
options: {
style: 'currency',
currency,
currencyDisplay
}
}).find(({
type
}) => type === 'currency')?.value || currency, currencyDisplay);
}
//# sourceMappingURL=separators.js.map