Auto-commit 2026-04-29 16:31

This commit is contained in:
2026-04-29 16:31:27 -04:00
parent e8687bb6b2
commit 0495ee5bd2
19691 changed files with 3272886 additions and 138 deletions

40
node_modules/strnum/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,40 @@
**2.2.2 / 2026-03-23**
- fix for space string
**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**
- fix e-notation
- to return string when invalid enotation is found. Eg `E24`
- to return valid number when only leading zero before e char is present
**2.0.5 / 2025-02-27**
- changes done in 1.1.2
**1.1.2 / 2025-02-27**
- fix skiplike for 0
**1.1.1 / 2025-02-21**
- All recent fixes of version 2
**2.0.4 / 2025-02-20**
- remove console log
**2.0.3 / 2025-02-20**
- fix for string which are falsly identified as e-notation
**2.0.1 / 2025-02-20**
- fix: handle only zeros
- fix: return original string when NaN
**2.0.0 / 2025-02-20**
- Migrating to ESM modules. No functional change
**1.1.0 / 2025-02-20**
- fix (#9): support missing floating point and e notations

21
node_modules/strnum/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 Natural Intelligence
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

104
node_modules/strnum/README.md generated vendored Normal file
View File

@@ -0,0 +1,104 @@
# strnum
Parse string into Number based on configuration
## Users
<a href="https://github.com/aws-amplify" target="_blank"><img src="https://avatars.githubusercontent.com/u/41077760?s=100&v=4"></a>
<a href="https://github.com/astrapay" target="_blank"><img src="https://avatars.githubusercontent.com/u/90901882?s=100&v=4"></a>
<a href="https://github.com/process-analytics" target="_blank"><img src="https://avatars.githubusercontent.com/u/60110287?s=100&v=4"></a>
<a href="https://github.com/NaturalIntelligence" target="_blank"><img src="https://avatars.githubusercontent.com/u/16322633?s=100&v=4"></a>
Many React Native projects and plugins
## Usage
```bash
npm install strnum
```
```js
const toNumber = require("strnum");
toNumber(undefined) // undefined
toNumber(null)) //null
toNumber("")) // ""
toNumber("string"); //"string")
toNumber("12,12"); //"12,12")
toNumber("12 12"); //"12 12")
toNumber("12-12"); //"12-12")
toNumber("12.12.12"); //"12.12.12")
toNumber("0x2f"); //47)
toNumber("-0x2f"); //-47)
toNumber("0x2f", { hex : true}); //47)
toNumber("-0x2f", { hex : true}); //-47)
toNumber("0x2f", { hex : false}); //"0x2f")
toNumber("-0x2f", { hex : false}); //"-0x2f")
toNumber("06"); //6)
toNumber("06", { leadingZeros : true}); //6)
toNumber("06", { leadingZeros : false}); //"06")
toNumber("006"); //6)
toNumber("006", { leadingZeros : true}); //6)
toNumber("006", { leadingZeros : false}); //"006")
toNumber("0.0"); //0)
toNumber("00.00"); //0)
toNumber("0.06"); //0.06)
toNumber("00.6"); //0.6)
toNumber(".006"); //0.006)
toNumber("6.0"); //6)
toNumber("06.0"); //6)
toNumber("0.0", { leadingZeros : false}); //0)
toNumber("00.00", { leadingZeros : false}); //"00.00")
toNumber("0.06", { leadingZeros : false}); //0.06)
toNumber("00.6", { leadingZeros : false}); //"00.6")
toNumber(".006", { leadingZeros : false}); //0.006)
toNumber("6.0" , { leadingZeros : false}); //6)
toNumber("06.0" , { leadingZeros : false}); //"06.0")
toNumber("-06"); //-6)
toNumber("-06", { leadingZeros : true}); //-6)
toNumber("-06", { leadingZeros : false}); //"-06")
toNumber("-0.0"); //-0)
toNumber("-00.00"); //-0)
toNumber("-0.06"); //-0.06)
toNumber("-00.6"); //-0.6)
toNumber("-.006"); //-0.006)
toNumber("-6.0"); //-6)
toNumber("-06.0"); //-6)
toNumber("-0.0" , { leadingZeros : false}); //-0)
toNumber("-00.00", { leadingZeros : false}); //"-00.00")
toNumber("-0.06", { leadingZeros : false}); //-0.06)
toNumber("-00.6", { leadingZeros : false}); //"-00.6")
toNumber("-.006", {leadingZeros : false}); //-0.006)
toNumber("-6.0" , { leadingZeros : false}); //-6)
toNumber("-06.0" , { leadingZeros : false}); //"-06.0")
toNumber("420926189200190257681175017717") ; //4.209261892001902e+29)
toNumber("000000000000000000000000017717" , { leadingZeros : false}); //"000000000000000000000000017717")
toNumber("000000000000000000000000017717" , { leadingZeros : true}); //17717)
toNumber("01.0e2" , { leadingZeros : false}); //"01.0e2")
toNumber("-01.0e2" , { leadingZeros : false}); //"-01.0e2")
toNumber("01.0e2") ; //100)
toNumber("-01.0e2") ; //-100)
toNumber("1.0e2") ; //100)
toNumber("-1.0e2") ; //-100)
toNumber("1.0e-2"); //0.01)
toNumber("+1212121212"); // 1212121212
toNumber("+1212121212", { skipLike: /\+[0-9]{10}/} )); //"+1212121212"
```
Supported Options
```js
hex: true, //when hexadecimal string should be parsed
leadingZeros: true, //when number with leading zeros like 08 should be parsed. 0.0 is not impacted
eNotation: true, //when number with eNotation or number parsed in eNotation should be considered
skipLike: /regex/ //when string should not be parsed when it matches the specified regular expression
infinity: "original", // "null", "infinity" (Infinity type), "string" ("Infinity" (the string literal))
```
# Try out our other work
WishIn - You need it if negative thoughts take over all the time <br>
<a href="https://play.google.com/store/apps/details?id=com.solothought.wishin"> <img src="https://solothought.com/products/assets/images/wishin/YouTubeThumbnail.png" width="500px"/> </a>

31
node_modules/strnum/package.json generated vendored Normal file
View File

@@ -0,0 +1,31 @@
{
"name": "strnum",
"version": "2.2.3",
"description": "Parse String to Number based on configuration",
"type": "module",
"main": "strnum.js",
"scripts": {
"test": "jasmine tests/*_test.js"
},
"keywords": [
"string",
"number",
"parse",
"convert"
],
"repository": {
"type": "git",
"url": "https://github.com/NaturalIntelligence/strnum"
},
"author": "Amit Gupta (https://amitkumargupta.work/)",
"license": "MIT",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/NaturalIntelligence"
}
],
"devDependencies": {
"jasmine": "^5.6.0"
}
}

161
node_modules/strnum/strnum.js generated vendored Normal file
View File

@@ -0,0 +1,161 @@
const hexRegex = /^[-+]?0x[a-fA-F0-9]+$/;
const numRegex = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/;
// const octRegex = /^0x[a-z0-9]+/;
// const binRegex = /0x[a-z0-9]+/;
const consider = {
hex: true,
// oct: false,
leadingZeros: true,
decimalPoint: "\.",
eNotation: true,
//skipLike: /regex/,
infinity: "original", // "null", "infinity" (Infinity type), "string" ("Infinity" (the string literal))
};
export default function toNumber(str, options = {}) {
options = Object.assign({}, consider, options);
if (!str || typeof str !== "string") return str;
let trimmedStr = str.trim();
if (trimmedStr.length === 0) return str;
else if (options.skipLike !== undefined && options.skipLike.test(trimmedStr)) return str;
else if (trimmedStr === "0") return 0;
else if (options.hex && hexRegex.test(trimmedStr)) {
return parse_int(trimmedStr, 16);
// }else if (options.oct && octRegex.test(str)) {
// return Number.parseInt(val, 8);
} else if (!isFinite(trimmedStr)) { //Infinity
return handleInfinity(str, Number(trimmedStr), options);
} else if (trimmedStr.includes('e') || trimmedStr.includes('E')) { //eNotation
return resolveEnotation(str, trimmedStr, options);
// }else if (options.parseBin && binRegex.test(str)) {
// return Number.parseInt(val, 2);
} else {
//separate negative sign, leading zeros, and rest number
const match = numRegex.exec(trimmedStr);
// +00.123 => [ , '+', '00', '.123', ..
if (match) {
const sign = match[1] || "";
const leadingZeros = match[2];
let numTrimmedByZeros = trimZeros(match[3]); //complete num without leading zeros
const decimalAdjacentToLeadingZeros = sign ? // 0., -00., 000.
str[leadingZeros.length + 1] === "."
: str[leadingZeros.length] === ".";
//trim ending zeros for floating number
if (!options.leadingZeros //leading zeros are not allowed
&& (leadingZeros.length > 1
|| (leadingZeros.length === 1 && !decimalAdjacentToLeadingZeros))) {
// 00, 00.3, +03.24, 03, 03.24
return str;
}
else {//no leading zeros or leading zeros are allowed
const num = Number(trimmedStr);
const parsedStr = String(num);
if (num === 0) return num;
if (parsedStr.search(/[eE]/) !== -1) { //given number is long and parsed to eNotation
if (options.eNotation) return num;
else return str;
} else if (trimmedStr.indexOf(".") !== -1) { //floating number
if (parsedStr === "0") return num; //0.0
else if (parsedStr === numTrimmedByZeros) return num; //0.456. 0.79000
else if (parsedStr === `${sign}${numTrimmedByZeros}`) return num;
else return str;
}
let n = leadingZeros ? numTrimmedByZeros : trimmedStr;
if (leadingZeros) {
// -009 => -9
return (n === parsedStr) || (sign + n === parsedStr) ? num : str
} else {
// +9
return (n === parsedStr) || (n === sign + parsedStr) ? num : str
}
}
} else { //non-numeric string
return str;
}
}
}
const eNotationRegx = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;
function resolveEnotation(str, trimmedStr, options) {
if (!options.eNotation) return str;
const notation = trimmedStr.match(eNotationRegx);
if (notation) {
let sign = notation[1] || "";
const eChar = notation[3].indexOf("e") === -1 ? "E" : "e";
const leadingZeros = notation[2];
const eAdjacentToLeadingZeros = sign ? // 0E.
str[leadingZeros.length + 1] === eChar
: str[leadingZeros.length] === eChar;
if (leadingZeros.length > 1 && eAdjacentToLeadingZeros) return str;
else if (leadingZeros.length === 1
&& (notation[3].startsWith(`.${eChar}`) || notation[3][0] === eChar)) {
return Number(trimmedStr);
} 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;
}
}
/**
*
* @param {string} numStr without leading zeros
* @returns
*/
function trimZeros(numStr) {
if (numStr && numStr.indexOf(".") !== -1) {//float
numStr = numStr.replace(/0+$/, ""); //remove ending zeros
if (numStr === ".") numStr = "0";
else if (numStr[0] === ".") numStr = "0" + numStr;
else if (numStr[numStr.length - 1] === ".") numStr = numStr.substring(0, numStr.length - 1);
return numStr;
}
return numStr;
}
function parse_int(numStr, base) {
//polyfill
if (parseInt) return parseInt(numStr, base);
else if (Number.parseInt) return Number.parseInt(numStr, base);
else if (window && window.parseInt) return window.parseInt(numStr, base);
else throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")
}
/**
* Handle infinite values based on user option
* @param {string} str - original input string
* @param {number} num - parsed number (Infinity or -Infinity)
* @param {object} options - user options
* @returns {string|number|null} based on infinity option
*/
function handleInfinity(str, num, options) {
const isPositive = num === Infinity;
switch (options.infinity.toLowerCase()) {
case "null":
return null;
case "infinity":
return num; // Return Infinity or -Infinity
case "string":
return isPositive ? "Infinity" : "-Infinity";
case "original":
default:
return str; // Return original string like "1e1000"
}
}