Explorar o código

feat(util): 小数位数处理

zhangweicheng %!s(int64=2) %!d(string=hai) anos
pai
achega
9cddf342cb
Modificáronse 2 ficheiros con 3 adicións e 3 borrados
  1. 2 2
      util/package.json
  2. 1 1
      util/src/math.ts

+ 2 - 2
util/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@sc/util",
-  "version": "1.0.11",
+  "version": "1.0.12",
   "description": "通用的工具包",
   "main": "./dist/index.cjs.js",
   "module": "./dist/index.esm.js",
@@ -50,4 +50,4 @@
   "dependencies": {
     "lodash": "^4.17.21"
   }
-}
+}

+ 1 - 1
util/src/math.ts

@@ -24,7 +24,7 @@ export const innerRound = (num: number, length: number, decimal: number): number
 export const roundForObj = (obj: string | number | undefined | null, decimal: number): number => {
   let value;
   if (obj === undefined || obj === null || isNaN(obj as number)) return 0;
-  const length = 10;
+  const length = decimal + 2;
   if (obj === +obj) {
     value = innerRound(obj, length, decimal);
   } else {