+1
-1
| { | ||
| "name": "wft-utils", | ||
| "version": "1.52.0", | ||
| "version": "1.52.1", | ||
| "description": "The commonly used tool functions in daily development", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
+13
-17
@@ -1075,21 +1075,17 @@ /** | ||
| */ | ||
| export function numberToCurrencyNo(value) { | ||
| export function numberToCurrencyNo(value, decimals = 2) { | ||
| if (!value) return '0' | ||
| if (value === '--') return '--' | ||
| value = value - 0 | ||
| // 将数值截取,保留0位小数 | ||
| value = value.toFixed(0) | ||
| // 获取整数部分 | ||
| const intPart = Math.trunc(value) | ||
| // 整数部分处理,增加, | ||
| const intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') | ||
| // 预定义小数部分 | ||
| let floatPart = '' | ||
| // 将数值截取为小数部分和整数部分 | ||
| const valueArray = value.toString().split('.') | ||
| if (valueArray.length === 2) { // 有小数部分 | ||
| floatPart = valueArray[1].toString() // 取得小数部分 | ||
| return intPartFormat + '.' + floatPart | ||
| } | ||
| return intPartFormat + floatPart | ||
| const num = Number(value) | ||
| if (isNaN(num)) return '0' | ||
| const fixedNum = num.toFixed(decimals) | ||
| const [intStr, floatStr] = fixedNum.split('.') | ||
| const intFormat = intStr.replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') | ||
| if (!floatStr) return intFormat | ||
| // 去掉小数末尾无用的 0 | ||
| const trimFloat = floatStr.replace(/0+$/, '') | ||
| return trimFloat ? `${intFormat}.${trimFloat}` : intFormat | ||
| } | ||
@@ -1096,0 +1092,0 @@ |
AI-detected potential malware
Supply chain riskAI has identified this package as malware. This is a strong signal that the package may be malicious.
100531
-0.2%3324
-0.21%1
Infinity%