better-bytes
Advanced tools
Comparing version
@@ -75,16 +75,12 @@ var __defProp = Object.defineProperty; | ||
} | ||
if (NUMBER_REG.test(data)) { | ||
const floatValue2 = Number.parseFloat(data); | ||
if (!Number.isFinite(floatValue2) || floatValue2 < 0) { | ||
return null; | ||
} | ||
return Math.floor(floatValue2); | ||
} | ||
const { forceKilobinary = false } = options; | ||
const results = PARSE_REG_EXP.exec(data); | ||
const floatValue = Number.parseFloat(results?.[1] || data); | ||
const unit = results?.[4]?.toLowerCase(); | ||
const floatValue = !unit && NUMBER_REG.test(data) ? Number.parseFloat(data) : Number.parseFloat(results?.[1]); | ||
if (!Number.isFinite(floatValue) || floatValue < 0) { | ||
return null; | ||
} | ||
if (!unit) { | ||
return Math.floor(floatValue); | ||
} | ||
let i = 0; | ||
@@ -91,0 +87,0 @@ let standard; |
{ | ||
"name": "better-bytes", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "Better byte base conversion. Supports two base conversions: kilo binary byte (2^10) and kilobyte (10^3).\n更好的字节进制换算。支持 千位二进制字节(2^10) 和 千字节(10^3) 两种进制换算", | ||
@@ -5,0 +5,0 @@ "author": "CaoMeiYouRen", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
36859
-1.56%281
-2.77%