UNPKG

@modern-kit/utils

Version:
25 lines (22 loc) 822 B
import { formatValueWithSymbol } from '../formatValueWithSymbol/index.mjs'; import { formatNumberWithCommas } from '../formatNumberWithCommas/index.mjs'; import { isNumber } from '../../validator/isNumber/index.mjs'; const getKRWSymbolOptions = (isSymbol) => { return isSymbol ? { prefix: "\u20A9" } : { suffix: "\uC6D0" }; }; function formatCurrencyKRW(value, options = {}) { const { isSymbol = false, decimal = 0 } = options; const valueToUse = isNumber(value) ? value : Number(value); const negativeSign = valueToUse < 0 ? "-" : ""; const absoluteValue = Math.abs(valueToUse); return `${negativeSign}${formatValueWithSymbol( formatNumberWithCommas(absoluteValue.toFixed(decimal)), getKRWSymbolOptions(isSymbol) )}`; } export { formatCurrencyKRW }; //# sourceMappingURL=index.mjs.map