| import toNumber from "../strnum.js"; | ||
| console.log(toNumber("1.5e3", {leadingZeros: false})) | ||
| // describe("temp", () = { | ||
| // it("scientific notation", () => { | ||
| // }); | ||
| // }) |
+5
-2
| **2.1.1 / 2025-05-15** | ||
| - remove unnecessary check to remove lint error | ||
| **2.2.1 / 2026-03-19** | ||
| - fix false positive for eNotation when no leading zeros | ||
| **2.2.0 / 2026-02-28** | ||
| - support infinity | ||
| **2.1.0 / 2025-05-01** | ||
@@ -6,0 +9,0 @@ - fix e-notation |
+1
-1
| { | ||
| "name": "strnum", | ||
| "version": "2.2.0", | ||
| "version": "2.2.1", | ||
| "description": "Parse String to Number based on configuration", | ||
@@ -5,0 +5,0 @@ "type": "module", |
+9
-4
@@ -100,7 +100,12 @@ const hexRegex = /^[-+]?0x[a-fA-F0-9]+$/; | ||
| return Number(trimmedStr); | ||
| } else if (options.leadingZeros && !eAdjacentToLeadingZeros) { //accept with leading zeros | ||
| //remove leading 0s | ||
| trimmedStr = (notation[1] || "") + notation[3]; | ||
| } else if (leadingZeros.length > 0) { | ||
| // Has leading zeros — only accept if leadingZeros option allows it | ||
| if (options.leadingZeros && !eAdjacentToLeadingZeros) { | ||
| trimmedStr = (notation[1] || "") + notation[3]; | ||
| return Number(trimmedStr); | ||
| } else return str; | ||
| } else { | ||
| // No leading zeros — always valid e-notation, parse it | ||
| return Number(trimmedStr); | ||
| } else return str; | ||
| } | ||
| } else { | ||
@@ -107,0 +112,0 @@ return str; |
@@ -129,2 +129,4 @@ import toNumber from "../strnum.js"; | ||
| expect(toNumber("1.e+2")).toEqual(100); | ||
| expect(toNumber("1.5e3", { leadingZeros: false })).toEqual(1500); | ||
| }); | ||
@@ -131,0 +133,0 @@ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
25653
2.05%11
10%343
3.31%0
-100%