@cdk8s/awscdk-resolver 0.0.318 → 0.0.319
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +3 -3
- package/lib/resolve.js +1 -1
- package/node_modules/@aws-sdk/client-cloudformation/package.json +14 -14
- package/node_modules/@aws-sdk/client-sso/package.json +13 -13
- package/node_modules/@aws-sdk/core/package.json +4 -4
- package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-http/package.json +6 -6
- package/node_modules/@aws-sdk/credential-provider-ini/package.json +8 -8
- package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
- package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
- package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
- package/node_modules/@aws-sdk/middleware-user-agent/package.json +4 -4
- package/node_modules/@aws-sdk/nested-clients/package.json +13 -13
- package/node_modules/@aws-sdk/token-providers/package.json +3 -3
- package/node_modules/@aws-sdk/util-endpoints/dist-cjs/index.js +30 -0
- package/node_modules/@aws-sdk/util-endpoints/dist-es/index.js +1 -0
- package/node_modules/@aws-sdk/util-endpoints/dist-es/resolveDefaultAwsRegionalEndpointsConfig.js +21 -0
- package/node_modules/@aws-sdk/util-endpoints/dist-types/index.d.ts +1 -0
- package/node_modules/@aws-sdk/util-endpoints/dist-types/resolveDefaultAwsRegionalEndpointsConfig.d.ts +56 -0
- package/node_modules/@aws-sdk/util-endpoints/dist-types/ts3.4/index.d.ts +1 -0
- package/node_modules/@aws-sdk/util-endpoints/dist-types/ts3.4/resolveDefaultAwsRegionalEndpointsConfig.d.ts +35 -0
- package/node_modules/@aws-sdk/util-endpoints/package.json +2 -1
- package/node_modules/@aws-sdk/util-user-agent-node/package.json +2 -2
- package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +20 -20
- package/node_modules/@smithy/core/dist-cjs/submodules/schema/index.js +80 -6
- package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpBindingProtocol.js +20 -20
- package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/ErrorSchema.js +10 -0
- package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/ListSchema.js +10 -0
- package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/MapSchema.js +10 -0
- package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/NormalizedSchema.js +10 -0
- package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/SimpleSchema.js +10 -0
- package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/StructureSchema.js +10 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/HttpBindingProtocol.d.ts +1 -1
- package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/ErrorSchema.d.ts +3 -0
- package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/ListSchema.d.ts +3 -0
- package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/MapSchema.d.ts +3 -0
- package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/NormalizedSchema.d.ts +3 -0
- package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/SimpleSchema.d.ts +3 -0
- package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/StructureSchema.d.ts +3 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/HttpBindingProtocol.d.ts +1 -1
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/ErrorSchema.d.ts +3 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/ListSchema.d.ts +3 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/MapSchema.d.ts +3 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/NormalizedSchema.d.ts +3 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/SimpleSchema.d.ts +3 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/StructureSchema.d.ts +3 -0
- package/node_modules/@smithy/core/package.json +2 -2
- package/node_modules/@smithy/fetch-http-handler/dist-cjs/index.js +2 -2
- package/node_modules/@smithy/fetch-http-handler/dist-es/fetch-http-handler.js +4 -4
- package/node_modules/@smithy/fetch-http-handler/dist-types/fetch-http-handler.d.ts +1 -1
- package/node_modules/@smithy/fetch-http-handler/dist-types/ts3.4/fetch-http-handler.d.ts +1 -1
- package/node_modules/@smithy/fetch-http-handler/package.json +1 -1
- package/node_modules/@smithy/middleware-endpoint/dist-cjs/index.js +5 -2
- package/node_modules/@smithy/middleware-endpoint/dist-es/adaptors/createConfigValueProvider.js +3 -0
- package/node_modules/@smithy/middleware-endpoint/dist-es/adaptors/getEndpointFromInstructions.js +1 -1
- package/node_modules/@smithy/middleware-endpoint/dist-es/endpointMiddleware.js +1 -1
- package/node_modules/@smithy/middleware-endpoint/dist-types/resolveEndpointConfig.d.ts +5 -2
- package/node_modules/@smithy/middleware-endpoint/dist-types/ts3.4/resolveEndpointConfig.d.ts +5 -2
- package/node_modules/@smithy/middleware-endpoint/package.json +2 -2
- package/node_modules/@smithy/middleware-retry/package.json +2 -2
- package/node_modules/@smithy/node-http-handler/dist-cjs/index.js +11 -9
- package/node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js +4 -3
- package/node_modules/@smithy/node-http-handler/dist-es/node-http2-handler.js +7 -6
- package/node_modules/@smithy/node-http-handler/dist-types/node-http-handler.d.ts +1 -1
- package/node_modules/@smithy/node-http-handler/dist-types/node-http2-handler.d.ts +1 -1
- package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/node-http-handler.d.ts +1 -1
- package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/node-http2-handler.d.ts +1 -1
- package/node_modules/@smithy/node-http-handler/package.json +1 -1
- package/node_modules/@smithy/smithy-client/package.json +4 -4
- package/node_modules/@smithy/util-defaults-mode-browser/package.json +2 -2
- package/node_modules/@smithy/util-defaults-mode-node/package.json +2 -2
- package/node_modules/@smithy/util-stream/package.json +3 -3
- package/node_modules/fast-xml-parser/CHANGELOG.md +77 -0
- package/node_modules/fast-xml-parser/README.md +39 -52
- package/node_modules/fast-xml-parser/lib/fxbuilder.min.js +2 -0
- package/node_modules/fast-xml-parser/lib/fxbuilder.min.js.map +1 -0
- package/node_modules/fast-xml-parser/lib/fxp.cjs +1 -0
- package/node_modules/fast-xml-parser/lib/fxp.d.cts +458 -0
- package/node_modules/fast-xml-parser/lib/fxp.min.js +2 -0
- package/node_modules/fast-xml-parser/lib/fxp.min.js.map +1 -0
- package/node_modules/fast-xml-parser/lib/fxparser.min.js +2 -0
- package/node_modules/fast-xml-parser/lib/fxparser.min.js.map +1 -0
- package/node_modules/fast-xml-parser/lib/fxvalidator.min.js +2 -0
- package/node_modules/fast-xml-parser/lib/fxvalidator.min.js.map +1 -0
- package/node_modules/fast-xml-parser/package.json +36 -20
- package/node_modules/fast-xml-parser/src/cli/cli.js +16 -12
- package/node_modules/fast-xml-parser/src/cli/man.js +6 -1
- package/node_modules/fast-xml-parser/src/cli/read.js +30 -79
- package/node_modules/fast-xml-parser/src/fxp.d.ts +52 -9
- package/node_modules/fast-xml-parser/src/fxp.js +11 -8
- package/node_modules/fast-xml-parser/src/ignoreAttributes.js +18 -0
- package/node_modules/fast-xml-parser/src/util.js +14 -18
- package/node_modules/fast-xml-parser/src/{v5 → v6}/CharsSymbol.js +1 -1
- package/node_modules/fast-xml-parser/src/{v5/valueParsers → v6}/EntitiesParser.js +3 -6
- package/node_modules/fast-xml-parser/src/{v5 → v6}/OptionsBuilder.js +3 -6
- package/node_modules/fast-xml-parser/src/{v5 → v6}/OutputBuilders/BaseOutputBuilder.js +1 -3
- package/node_modules/fast-xml-parser/src/{v5 → v6}/OutputBuilders/JsArrBuilder.js +3 -3
- package/node_modules/fast-xml-parser/src/{v5 → v6}/OutputBuilders/JsMinArrBuilder.js +3 -5
- package/node_modules/fast-xml-parser/src/{v5 → v6}/OutputBuilders/JsObjBuilder.js +3 -5
- package/node_modules/fast-xml-parser/src/{v5 → v6}/OutputBuilders/ParserOptionsBuilder.js +6 -11
- package/node_modules/fast-xml-parser/src/{v5 → v6}/TagPath.js +1 -1
- package/node_modules/fast-xml-parser/src/{v5 → v6}/TagPathMatcher.js +3 -5
- package/node_modules/fast-xml-parser/src/{v5 → v6}/XMLParser.js +3 -5
- package/node_modules/fast-xml-parser/src/{v5 → v6}/Xml2JsParser.js +8 -10
- package/node_modules/fast-xml-parser/src/{v5 → v6}/XmlPartReader.js +24 -26
- package/node_modules/fast-xml-parser/src/{v5 → v6}/XmlSpecialTagsReader.js +5 -12
- package/node_modules/fast-xml-parser/src/{v5 → v6}/inputSource/BufferSource.js +1 -3
- package/node_modules/fast-xml-parser/src/{v5 → v6}/inputSource/StringSource.js +1 -3
- package/node_modules/fast-xml-parser/src/{v5 → v6/valueParsers}/EntitiesParser.js +3 -5
- package/node_modules/fast-xml-parser/src/{v5 → v6}/valueParsers/booleanParser.js +1 -2
- package/node_modules/fast-xml-parser/src/{v5 → v6}/valueParsers/booleanParserExt.js +1 -2
- package/node_modules/fast-xml-parser/src/{v5 → v6}/valueParsers/currency.js +1 -3
- package/node_modules/fast-xml-parser/src/{v5 → v6}/valueParsers/join.js +1 -2
- package/node_modules/fast-xml-parser/src/{v5 → v6}/valueParsers/number.js +2 -4
- package/node_modules/fast-xml-parser/src/{v5 → v6}/valueParsers/trim.js +1 -3
- package/node_modules/fast-xml-parser/src/validator.js +5 -5
- package/node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js +17 -13
- package/node_modules/fast-xml-parser/src/xmlbuilder/orderedJs2Xml.js +1 -2
- package/node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js +288 -71
- package/node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js +3 -5
- package/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js +28 -23
- package/node_modules/fast-xml-parser/src/xmlparser/XMLParser.js +21 -8
- package/node_modules/fast-xml-parser/src/xmlparser/node2json.js +8 -2
- package/node_modules/fast-xml-parser/src/xmlparser/xmlNode.js +22 -7
- package/node_modules/strnum/.github/SECURITY.md +5 -0
- package/node_modules/strnum/CHANGELOG.md +11 -0
- package/node_modules/strnum/algo.stflow +84 -0
- package/node_modules/strnum/package.json +2 -1
- package/node_modules/strnum/strnum.js +53 -35
- package/node_modules/strnum/strnum.test.js +9 -1
- package/node_modules/strnum/test.js +9 -0
- package/package.json +4 -4
- /package/node_modules/fast-xml-parser/src/{v5 → v6}/Report.js +0 -0
@@ -1,6 +1,14 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
|
3
|
+
let METADATA_SYMBOL;
|
4
|
+
|
5
|
+
if (typeof Symbol !== "function") {
|
6
|
+
METADATA_SYMBOL = "@@xmlMetadata";
|
7
|
+
} else {
|
8
|
+
METADATA_SYMBOL = Symbol("XML Node Metadata");
|
9
|
+
}
|
10
|
+
|
11
|
+
export default class XmlNode{
|
4
12
|
constructor(tagname) {
|
5
13
|
this.tagname = tagname;
|
6
14
|
this.child = []; //nested tags, text, cdata, comments in order
|
@@ -11,15 +19,22 @@ class XmlNode{
|
|
11
19
|
if(key === "__proto__") key = "#__proto__";
|
12
20
|
this.child.push( {[key]: val });
|
13
21
|
}
|
14
|
-
addChild(node) {
|
22
|
+
addChild(node, startIndex) {
|
15
23
|
if(node.tagname === "__proto__") node.tagname = "#__proto__";
|
16
24
|
if(node[":@"] && Object.keys(node[":@"]).length > 0){
|
17
25
|
this.child.push( { [node.tagname]: node.child, [":@"]: node[":@"] });
|
18
26
|
}else{
|
19
27
|
this.child.push( { [node.tagname]: node.child });
|
20
28
|
}
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
29
|
+
// if requested, add the startIndex
|
30
|
+
if (startIndex !== undefined) {
|
31
|
+
// Note: for now we just overwrite the metadata. If we had more complex metadata,
|
32
|
+
// we might need to do an object append here: metadata = { ...metadata, startIndex }
|
33
|
+
this.child[this.child.length - 1][METADATA_SYMBOL] = { startIndex };
|
34
|
+
}
|
35
|
+
}
|
36
|
+
/** symbol used for metadata */
|
37
|
+
static getMetaDataSymbol() {
|
38
|
+
return METADATA_SYMBOL;
|
39
|
+
}
|
40
|
+
}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
If you believe you have found a security vulnerability in this repository which can be potentially harful for the users in anyway, please do not report security vulnerabilities through public GitHub issues. Instead, please report it to us as described below.
|
2
|
+
|
3
|
+
## Security contact information
|
4
|
+
|
5
|
+
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
|
@@ -1,4 +1,15 @@
|
|
1
1
|
|
2
|
+
**2.1.1 / 2025-05-15**
|
3
|
+
- remove unnecessary check to remove lint error
|
4
|
+
|
5
|
+
**2.1.0 / 2025-05-01**
|
6
|
+
- fix e-notation
|
7
|
+
- to return string when invalid enotation is found. Eg `E24`
|
8
|
+
- to return valid number when only leading zero before e char is present
|
9
|
+
|
10
|
+
**2.0.5 / 2025-02-27**
|
11
|
+
- changes done in 1.1.2
|
12
|
+
|
2
13
|
**1.1.2 / 2025-02-27**
|
3
14
|
- fix skiplike for 0
|
4
15
|
|
@@ -0,0 +1,84 @@
|
|
1
|
+
|
2
|
+
FLOW: toNumber
|
3
|
+
input: x, options
|
4
|
+
IF not string
|
5
|
+
END x
|
6
|
+
ELSE_IF should skip
|
7
|
+
END x
|
8
|
+
ELSE_IF 0
|
9
|
+
END 0
|
10
|
+
ELSE_IF hex is supported AND x is hex
|
11
|
+
END int of x of base 16
|
12
|
+
ELSE_IF possible e notation
|
13
|
+
FOLLOW: resolve enotation (x, trimmed x, options)
|
14
|
+
ELSE
|
15
|
+
IF match numeric pattern
|
16
|
+
separate sign, leading zeros, pure number
|
17
|
+
IF x doesn't starts with "[+-]0."
|
18
|
+
END number(x)
|
19
|
+
IF leading zeros are not allowed
|
20
|
+
IF leading zeros > 1
|
21
|
+
#00.1
|
22
|
+
END x
|
23
|
+
ELSE_IF leading zeros == 1 AND decimal is not adjacent to leading zeros
|
24
|
+
#06.5
|
25
|
+
#but not 0.65, .65, 6.0
|
26
|
+
END x
|
27
|
+
ELSE_IF str has only zeros
|
28
|
+
END 0
|
29
|
+
ELSE
|
30
|
+
parse x to number
|
31
|
+
IF parsed x == 0 or -0
|
32
|
+
END parsed x
|
33
|
+
ELSE_IF parsed x is eNotation
|
34
|
+
IF conversion to enotation is allowed
|
35
|
+
END parsed x
|
36
|
+
ELSE
|
37
|
+
END x
|
38
|
+
ELSE_IF floating number
|
39
|
+
IF parsed x is 0
|
40
|
+
END parsed x
|
41
|
+
ELSE_IF parsed x == number without leading 0s
|
42
|
+
#0.456. 0.79000
|
43
|
+
END parsed x
|
44
|
+
ELSE_IF parsed x is negative AND == parsed x == number without leading 0s
|
45
|
+
END parsed x
|
46
|
+
ELSE
|
47
|
+
END x
|
48
|
+
ELSE_IF leading 0s are present
|
49
|
+
IF parsed x == x without leading 0s
|
50
|
+
END parsed x
|
51
|
+
ELSE
|
52
|
+
END x
|
53
|
+
ELSE
|
54
|
+
IF parsed x == x (consider sign)
|
55
|
+
END parsed x
|
56
|
+
ELSE
|
57
|
+
END x
|
58
|
+
|
59
|
+
ELSE
|
60
|
+
END x
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
FLOW: resolve enotation
|
65
|
+
input: x, trimmed x, options
|
66
|
+
IF eNotation has not to be evaluated
|
67
|
+
END x
|
68
|
+
IF match eNotation pattern
|
69
|
+
extract sign, eChar, leading zeros
|
70
|
+
find if eChar adjacent to leading zeros
|
71
|
+
|
72
|
+
IF leading zeros > 1 AND eChar adjacent to leading zeros
|
73
|
+
# 00e, -00e
|
74
|
+
END x
|
75
|
+
ELSE_IF exp is `0e`, `0.e`, `-0.e`, `-0e`
|
76
|
+
END number(x);
|
77
|
+
ELSE_IF leading zeros are allowed but eChar is not adjacent to leading zeros
|
78
|
+
# -003e2
|
79
|
+
remove leading zeros
|
80
|
+
END number(x)
|
81
|
+
ELSE
|
82
|
+
END x
|
83
|
+
ELSE
|
84
|
+
END x
|
@@ -13,7 +13,7 @@ const consider = {
|
|
13
13
|
//skipLike: /regex/
|
14
14
|
};
|
15
15
|
|
16
|
-
function toNumber(str, options = {}){
|
16
|
+
export default function toNumber(str, options = {}){
|
17
17
|
options = Object.assign({}, consider, options );
|
18
18
|
if(!str || typeof str !== "string" ) return str;
|
19
19
|
|
@@ -25,23 +25,8 @@ function toNumber(str, options = {}){
|
|
25
25
|
return parse_int(trimmedStr, 16);
|
26
26
|
// }else if (options.oct && octRegex.test(str)) {
|
27
27
|
// return Number.parseInt(val, 8);
|
28
|
-
}else if (trimmedStr.search(
|
29
|
-
|
30
|
-
// +00.123 => [ , '+', '00', '.123', ..
|
31
|
-
if(notation){
|
32
|
-
// console.log(notation)
|
33
|
-
if(options.leadingZeros){ //accept with leading zeros
|
34
|
-
trimmedStr = (notation[1] || "") + notation[3];
|
35
|
-
}else{
|
36
|
-
if(notation[2] === "0" && notation[3][0]=== "."){ //valid number
|
37
|
-
}else{
|
38
|
-
return str;
|
39
|
-
}
|
40
|
-
}
|
41
|
-
return options.eNotation ? Number(trimmedStr) : str;
|
42
|
-
}else{
|
43
|
-
return str;
|
44
|
-
}
|
28
|
+
}else if (trimmedStr.search(/.+[eE].+/)!== -1) { //eNotation
|
29
|
+
return resolveEnotation(str,trimmedStr,options);
|
45
30
|
// }else if (options.parseBin && binRegex.test(str)) {
|
46
31
|
// return Number.parseInt(val, 2);
|
47
32
|
}else{
|
@@ -49,33 +34,42 @@ function toNumber(str, options = {}){
|
|
49
34
|
const match = numRegex.exec(trimmedStr);
|
50
35
|
// +00.123 => [ , '+', '00', '.123', ..
|
51
36
|
if(match){
|
52
|
-
const sign = match[1];
|
37
|
+
const sign = match[1] || "";
|
53
38
|
const leadingZeros = match[2];
|
54
39
|
let numTrimmedByZeros = trimZeros(match[3]); //complete num without leading zeros
|
40
|
+
const decimalAdjacentToLeadingZeros = sign ? // 0., -00., 000.
|
41
|
+
str[leadingZeros.length+1] === "."
|
42
|
+
: str[leadingZeros.length] === ".";
|
43
|
+
|
55
44
|
//trim ending zeros for floating number
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
45
|
+
if(!options.leadingZeros //leading zeros are not allowed
|
46
|
+
&& (leadingZeros.length > 1
|
47
|
+
|| (leadingZeros.length === 1 && !decimalAdjacentToLeadingZeros))){
|
48
|
+
// 00, 00.3, +03.24, 03, 03.24
|
49
|
+
return str;
|
50
|
+
}
|
61
51
|
else{//no leading zeros or leading zeros are allowed
|
62
52
|
const num = Number(trimmedStr);
|
63
|
-
const
|
53
|
+
const parsedStr = String(num);
|
64
54
|
|
65
|
-
if(
|
55
|
+
if( num === 0) return num;
|
56
|
+
if(parsedStr.search(/[eE]/) !== -1){ //given number is long and parsed to eNotation
|
66
57
|
if(options.eNotation) return num;
|
67
58
|
else return str;
|
68
59
|
}else if(trimmedStr.indexOf(".") !== -1){ //floating number
|
69
|
-
if(
|
70
|
-
else if(
|
71
|
-
else if(
|
60
|
+
if(parsedStr === "0") return num; //0.0
|
61
|
+
else if(parsedStr === numTrimmedByZeros) return num; //0.456. 0.79000
|
62
|
+
else if( parsedStr === `${sign}${numTrimmedByZeros}`) return num;
|
72
63
|
else return str;
|
73
64
|
}
|
74
65
|
|
66
|
+
let n = leadingZeros? numTrimmedByZeros : trimmedStr;
|
75
67
|
if(leadingZeros){
|
76
|
-
|
68
|
+
// -009 => -9
|
69
|
+
return (n === parsedStr) || (sign+n === parsedStr) ? num : str
|
77
70
|
}else {
|
78
|
-
|
71
|
+
// +9
|
72
|
+
return (n === parsedStr) || (n === sign+parsedStr) ? num : str
|
79
73
|
}
|
80
74
|
}
|
81
75
|
}else{ //non-numeric string
|
@@ -84,6 +78,32 @@ function toNumber(str, options = {}){
|
|
84
78
|
}
|
85
79
|
}
|
86
80
|
|
81
|
+
const eNotationRegx = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;
|
82
|
+
function resolveEnotation(str,trimmedStr,options){
|
83
|
+
if(!options.eNotation) return str;
|
84
|
+
const notation = trimmedStr.match(eNotationRegx);
|
85
|
+
if(notation){
|
86
|
+
let sign = notation[1] || "";
|
87
|
+
const eChar = notation[3].indexOf("e") === -1 ? "E" : "e";
|
88
|
+
const leadingZeros = notation[2];
|
89
|
+
const eAdjacentToLeadingZeros = sign ? // 0E.
|
90
|
+
str[leadingZeros.length+1] === eChar
|
91
|
+
: str[leadingZeros.length] === eChar;
|
92
|
+
|
93
|
+
if(leadingZeros.length > 1 && eAdjacentToLeadingZeros) return str;
|
94
|
+
else if(leadingZeros.length === 1
|
95
|
+
&& (notation[3].startsWith(`.${eChar}`) || notation[3][0] === eChar)){
|
96
|
+
return Number(trimmedStr);
|
97
|
+
}else if(options.leadingZeros && !eAdjacentToLeadingZeros){ //accept with leading zeros
|
98
|
+
//remove leading 0s
|
99
|
+
trimmedStr = (notation[1] || "") + notation[3];
|
100
|
+
return Number(trimmedStr);
|
101
|
+
}else return str;
|
102
|
+
}else{
|
103
|
+
return str;
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
87
107
|
/**
|
88
108
|
*
|
89
109
|
* @param {string} numStr without leading zeros
|
@@ -94,7 +114,7 @@ function trimZeros(numStr){
|
|
94
114
|
numStr = numStr.replace(/0+$/, ""); //remove ending zeros
|
95
115
|
if(numStr === ".") numStr = "0";
|
96
116
|
else if(numStr[0] === ".") numStr = "0"+numStr;
|
97
|
-
else if(numStr[numStr.length-1] === ".") numStr = numStr.
|
117
|
+
else if(numStr[numStr.length-1] === ".") numStr = numStr.substring(0,numStr.length-1);
|
98
118
|
return numStr;
|
99
119
|
}
|
100
120
|
return numStr;
|
@@ -106,6 +126,4 @@ function parse_int(numStr, base){
|
|
106
126
|
else if(Number.parseInt) return Number.parseInt(numStr, base);
|
107
127
|
else if(window && window.parseInt) return window.parseInt(numStr, base);
|
108
128
|
else throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")
|
109
|
-
}
|
110
|
-
|
111
|
-
module.exports = toNumber;
|
129
|
+
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
import toNumber from "./strnum.js";
|
2
2
|
|
3
3
|
describe("Should convert all the valid numeric strings to number", () => {
|
4
4
|
it("should return undefined, null, empty string, or non-numeric as it is", () => {
|
@@ -95,6 +95,7 @@ describe("Should convert all the valid numeric strings to number", () => {
|
|
95
95
|
expect(toNumber("-.006")).toEqual(-0.006);
|
96
96
|
expect(toNumber("-6.0")).toEqual(-6);
|
97
97
|
expect(toNumber("-06.0")).toEqual(-6);
|
98
|
+
expect(toNumber("+06.0")).toEqual(6);
|
98
99
|
|
99
100
|
expect(toNumber("-0.0" , { leadingZeros : false})).toEqual(-0);
|
100
101
|
expect(toNumber("-00.00", { leadingZeros : false})).toEqual("-00.00");
|
@@ -137,6 +138,13 @@ describe("Should convert all the valid numeric strings to number", () => {
|
|
137
138
|
|
138
139
|
expect(toNumber("-1.0E2") ).toEqual(-100);
|
139
140
|
expect(toNumber("1.0E-2")).toEqual(0.01);
|
141
|
+
|
142
|
+
expect(toNumber("E-2")).toEqual("E-2");
|
143
|
+
expect(toNumber("E2")).toEqual("E2");
|
144
|
+
expect(toNumber("0E2")).toEqual(0);
|
145
|
+
expect(toNumber("-0E2")).toEqual(-0);
|
146
|
+
expect(toNumber("00E2")).toEqual("00E2");
|
147
|
+
expect(toNumber("00E2", { leadingZeros : false})).toEqual("00E2");
|
140
148
|
});
|
141
149
|
|
142
150
|
it("should skip matching pattern", () => {
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import toNumber from "./strnum.js";
|
2
|
+
|
3
|
+
describe("Should convert all the valid numeric strings to number", () => {
|
4
|
+
it("should return undefined, null, empty string, or non-numeric as it is", () => {
|
5
|
+
// expect(toNumber("+ 90")).toEqual("+ 90");
|
6
|
+
// expect(toNumber("- 90")).toEqual("- 90");
|
7
|
+
expect(toNumber("-10E2")).toEqual(100);
|
8
|
+
});
|
9
|
+
});
|
package/package.json
CHANGED
@@ -52,7 +52,7 @@
|
|
52
52
|
"aws-cdk": "^2.1020.2",
|
53
53
|
"aws-cdk-lib": "2.195.0",
|
54
54
|
"cdk8s": "2.68.91",
|
55
|
-
"cdk8s-cli": "^2.200.
|
55
|
+
"cdk8s-cli": "^2.200.125",
|
56
56
|
"commit-and-tag-version": "^12",
|
57
57
|
"constructs": "10.3.0",
|
58
58
|
"eslint": "^9",
|
@@ -66,7 +66,7 @@
|
|
66
66
|
"jsii-docgen": "^10.5.0",
|
67
67
|
"jsii-pacmak": "^1.112.0",
|
68
68
|
"jsii-rosetta": "^5",
|
69
|
-
"projen": "^0.94.
|
69
|
+
"projen": "^0.94.1",
|
70
70
|
"ts-jest": "^27",
|
71
71
|
"ts-node": "^10.9.2",
|
72
72
|
"typescript": "^5.8.3"
|
@@ -77,7 +77,7 @@
|
|
77
77
|
"constructs": "^10.3.0"
|
78
78
|
},
|
79
79
|
"dependencies": {
|
80
|
-
"@aws-sdk/client-cloudformation": "^3.
|
80
|
+
"@aws-sdk/client-cloudformation": "^3.844.0"
|
81
81
|
},
|
82
82
|
"bundledDependencies": [
|
83
83
|
"@aws-sdk/client-cloudformation"
|
@@ -93,7 +93,7 @@
|
|
93
93
|
"publishConfig": {
|
94
94
|
"access": "public"
|
95
95
|
},
|
96
|
-
"version": "0.0.
|
96
|
+
"version": "0.0.319",
|
97
97
|
"jest": {
|
98
98
|
"coverageProvider": "v8",
|
99
99
|
"testMatch": [
|
File without changes
|