UNPKG

@cainiaofe/cn-utils

Version:

菜鸟前端基础工具库

47 lines (46 loc) 1.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.numberFormat = exports.getNumSysFormatConf = exports.getDecimalSeparator = void 0; var const_1 = require("../const"); /** * 通过语种获取当前数字系统小数点 * @param lang 语种 * @returns */ var getDecimalSeparator = function (lang) { return '.'; }; exports.getDecimalSeparator = getDecimalSeparator; /** * 通过语种获取当前数字系统格式化配置 * @param lang 语种 * @returns */ var getNumSysFormatConf = function (lang) { return { decimalSeparator: '.', groupSeparator: ',', groupSize: 3, secondaryGroupSize: 0, fractionGroupSeparator: ',', fractionGroupSize: 0, }; }; exports.getNumSysFormatConf = getNumSysFormatConf; /** *通过语种获取当前数字系统格式化字符串 * @param num * @param lang * @returns */ var numberFormat = function (num, lang) { try { var str = new Intl.NumberFormat(lang, const_1.STANDARD_NUM_SYS_OPTION).format(num); return str; } catch (error) { console.error(error); return num; } }; exports.numberFormat = numberFormat;