New:Socket for Asana Is Now Available.Learn more
Get Started

strnum

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

strnum - npm Package Compare versions

Comparing version
2.4.1
to
2.4.2
+6
-0
CHANGELOG.md
**2.4.2 / 2026-08-14**
- fix: trimZeros to avoid quadratic complexity
**2.4.1 / 2026-06-18**
- deps: update anynum to 1.0.1
**2.4.0 / 2026-06-09**

@@ -3,0 +9,0 @@ - support unicode numerals using 'anynum'

+1
-1
{
"name": "strnum",
"version": "2.4.1",
"version": "2.4.2",
"description": "Parse String to Number based on configuration",

@@ -5,0 +5,0 @@ "type": "module",

@@ -131,3 +131,7 @@ const hexRegex = /^[-+]?0x[a-fA-F0-9]+$/;

if (numStr && numStr.indexOf(".") !== -1) {//float
numStr = numStr.replace(/0+$/, ""); //remove ending zeros
//remove ending zeros without the O(n^2) backtracking that /0+$/ hits
//when the string doesn't end in 0 but has a long internal zero-run
let end = numStr.length;
while (end > 0 && numStr.charCodeAt(end - 1) === 48 /* '0' */) end--;
numStr = numStr.slice(0, end);
if (numStr === ".") numStr = "0";

@@ -134,0 +138,0 @@ else if (numStr[0] === ".") numStr = "0" + numStr;