@cdk8s/awscdk-resolver 0.0.608 → 0.0.610

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.
Files changed (145) hide show
  1. package/.jsii +3 -3
  2. package/lib/resolve.js +1 -1
  3. package/node_modules/@aws-sdk/client-cloudformation/package.json +3 -3
  4. package/node_modules/@aws-sdk/core/package.json +2 -2
  5. package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
  6. package/node_modules/@aws-sdk/credential-provider-http/package.json +2 -2
  7. package/node_modules/@aws-sdk/credential-provider-ini/package.json +9 -9
  8. package/node_modules/@aws-sdk/credential-provider-login/package.json +3 -3
  9. package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
  10. package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
  11. package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
  12. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
  13. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
  14. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
  15. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
  16. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
  17. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
  18. package/node_modules/@aws-sdk/nested-clients/package.json +2 -2
  19. package/node_modules/@aws-sdk/token-providers/package.json +3 -3
  20. package/node_modules/@aws-sdk/xml-builder/dist-cjs/xml-parser.browser.js +1 -1
  21. package/node_modules/@aws-sdk/xml-builder/dist-cjs/xml-parser.js +233 -43
  22. package/node_modules/@aws-sdk/xml-builder/dist-es/xml-parser.browser.js +1 -1
  23. package/node_modules/@aws-sdk/xml-builder/dist-es/xml-parser.js +233 -43
  24. package/node_modules/@aws-sdk/xml-builder/dist-types/ts3.4/xml-parser.d.ts +1 -1
  25. package/node_modules/@aws-sdk/xml-builder/dist-types/xml-parser.d.ts +2 -1
  26. package/node_modules/@aws-sdk/xml-builder/package.json +4 -4
  27. package/node_modules/@smithy/core/dist-cjs/submodules/cbor/index.js +518 -371
  28. package/node_modules/@smithy/core/dist-cjs/submodules/client/index.js +1 -1
  29. package/node_modules/@smithy/core/dist-es/submodules/cbor/cbor-decode.js +326 -269
  30. package/node_modules/@smithy/core/dist-es/submodules/cbor/cbor-encode.js +192 -103
  31. package/node_modules/@smithy/core/dist-es/submodules/cbor/cbor.js +4 -2
  32. package/node_modules/@smithy/core/dist-es/submodules/client/smithy-client/get-value-from-text-node.js +1 -1
  33. package/node_modules/@smithy/core/dist-types/submodules/cbor/cbor-decode.d.ts +4 -0
  34. package/node_modules/@smithy/core/dist-types/submodules/cbor/cbor-encode.d.ts +8 -4
  35. package/node_modules/@smithy/core/package.json +1 -1
  36. package/node_modules/@smithy/credential-provider-imds/package.json +2 -2
  37. package/node_modules/@smithy/fetch-http-handler/package.json +2 -2
  38. package/node_modules/@smithy/node-http-handler/package.json +2 -2
  39. package/node_modules/@smithy/signature-v4/package.json +2 -2
  40. package/package.json +6 -6
  41. package/node_modules/@aws-sdk/xml-builder/dist-cjs/xml-external/nodable_entities.js +0 -333
  42. package/node_modules/@aws-sdk/xml-builder/dist-es/xml-external/nodable_entities.js +0 -332
  43. package/node_modules/@aws-sdk/xml-builder/dist-types/ts3.4/xml-external/nodable_entities.d.ts +0 -66
  44. package/node_modules/@aws-sdk/xml-builder/dist-types/xml-external/nodable_entities.d.ts +0 -65
  45. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/CHANGELOG.md +0 -827
  46. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/LICENSE +0 -21
  47. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/README.md +0 -202
  48. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxbuilder.min.js +0 -2
  49. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxbuilder.min.js.map +0 -1
  50. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.cjs +0 -1
  51. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.d.cts +0 -770
  52. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.min.js +0 -2
  53. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.min.js.map +0 -1
  54. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxparser.min.js +0 -2
  55. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxparser.min.js.map +0 -1
  56. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxvalidator.min.js +0 -2
  57. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxvalidator.min.js.map +0 -1
  58. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/package.json +0 -93
  59. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/cli/cli.js +0 -97
  60. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/cli/man.js +0 -17
  61. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/cli/read.js +0 -43
  62. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/fxp.d.ts +0 -739
  63. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/fxp.js +0 -14
  64. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/ignoreAttributes.js +0 -18
  65. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/util.js +0 -61
  66. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/CharsSymbol.js +0 -16
  67. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/EntitiesParser.js +0 -106
  68. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/OptionsBuilder.js +0 -61
  69. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/OutputBuilders/BaseOutputBuilder.js +0 -69
  70. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsArrBuilder.js +0 -103
  71. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsMinArrBuilder.js +0 -100
  72. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsObjBuilder.js +0 -154
  73. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/OutputBuilders/ParserOptionsBuilder.js +0 -94
  74. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/Report.js +0 -0
  75. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/TagPath.js +0 -81
  76. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/TagPathMatcher.js +0 -13
  77. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/XMLParser.js +0 -83
  78. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/Xml2JsParser.js +0 -235
  79. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/XmlPartReader.js +0 -210
  80. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/XmlSpecialTagsReader.js +0 -111
  81. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/inputSource/BufferSource.js +0 -116
  82. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/inputSource/StringSource.js +0 -121
  83. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/EntitiesParser.js +0 -105
  84. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/booleanParser.js +0 -22
  85. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/booleanParserExt.js +0 -19
  86. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/currency.js +0 -38
  87. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/join.js +0 -13
  88. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/number.js +0 -14
  89. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/trim.js +0 -6
  90. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/validator.js +0 -425
  91. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js +0 -6
  92. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js +0 -407
  93. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js +0 -163
  94. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js +0 -840
  95. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/XMLParser.js +0 -71
  96. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/node2json.js +0 -177
  97. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/xmlNode.js +0 -40
  98. package/node_modules/@nodable/entities/README.md +0 -41
  99. package/node_modules/@nodable/entities/package.json +0 -57
  100. package/node_modules/@nodable/entities/src/EntityDecoder.js +0 -644
  101. package/node_modules/@nodable/entities/src/EntityEncoder.js +0 -194
  102. package/node_modules/@nodable/entities/src/entities.js +0 -1159
  103. package/node_modules/@nodable/entities/src/entityTries.js +0 -49
  104. package/node_modules/@nodable/entities/src/index.d.ts +0 -341
  105. package/node_modules/@nodable/entities/src/index.js +0 -29
  106. package/node_modules/anynum/LICENSE +0 -21
  107. package/node_modules/anynum/README.md +0 -142
  108. package/node_modules/anynum/anynum.js +0 -135
  109. package/node_modules/anynum/digitTable.js +0 -116
  110. package/node_modules/anynum/package.json +0 -42
  111. package/node_modules/fast-xml-builder/CHANGELOG.md +0 -40
  112. package/node_modules/fast-xml-builder/LICENSE +0 -21
  113. package/node_modules/fast-xml-builder/README.md +0 -74
  114. package/node_modules/fast-xml-builder/lib/fxb.cjs +0 -1
  115. package/node_modules/fast-xml-builder/lib/fxb.d.cts +0 -270
  116. package/node_modules/fast-xml-builder/lib/fxb.min.js +0 -2
  117. package/node_modules/fast-xml-builder/lib/fxb.min.js.map +0 -1
  118. package/node_modules/fast-xml-builder/package.json +0 -81
  119. package/node_modules/fast-xml-builder/src/fxb.d.ts +0 -270
  120. package/node_modules/fast-xml-builder/src/fxb.js +0 -599
  121. package/node_modules/fast-xml-builder/src/ignoreAttributes.js +0 -18
  122. package/node_modules/fast-xml-builder/src/orderedJs2Xml.js +0 -359
  123. package/node_modules/fast-xml-builder/src/prettifyJs2Xml.js +0 -0
  124. package/node_modules/fast-xml-builder/src/util.js +0 -16
  125. package/node_modules/path-expression-matcher/LICENSE +0 -21
  126. package/node_modules/path-expression-matcher/README.md +0 -947
  127. package/node_modules/path-expression-matcher/lib/pem.cjs +0 -1
  128. package/node_modules/path-expression-matcher/lib/pem.d.cts +0 -715
  129. package/node_modules/path-expression-matcher/lib/pem.min.js +0 -2
  130. package/node_modules/path-expression-matcher/lib/pem.min.js.map +0 -1
  131. package/node_modules/path-expression-matcher/package.json +0 -79
  132. package/node_modules/path-expression-matcher/src/Expression.js +0 -232
  133. package/node_modules/path-expression-matcher/src/ExpressionSet.js +0 -225
  134. package/node_modules/path-expression-matcher/src/Matcher.js +0 -660
  135. package/node_modules/path-expression-matcher/src/index.d.ts +0 -589
  136. package/node_modules/path-expression-matcher/src/index.js +0 -29
  137. package/node_modules/strnum/CHANGELOG.md +0 -51
  138. package/node_modules/strnum/LICENSE +0 -21
  139. package/node_modules/strnum/README.md +0 -113
  140. package/node_modules/strnum/package.json +0 -36
  141. package/node_modules/strnum/strnum.js +0 -171
  142. package/node_modules/xml-naming/README.md +0 -189
  143. package/node_modules/xml-naming/package.json +0 -54
  144. package/node_modules/xml-naming/src/index.d.ts +0 -74
  145. package/node_modules/xml-naming/src/index.js +0 -270
@@ -1,113 +0,0 @@
1
- # strnum
2
- Parse string into Number based on configuration
3
-
4
- [![strnum downloads](https://img.shields.io/npm/dw/strnum.svg)](https://npm-compare.com/strnum)
5
- [![strnum version](https://img.shields.io/npm/v/strnum.svg)](https://www.npmjs.com/package/strnum)
6
- [![strnum license](https://img.shields.io/npm/l/strnum.svg)](https://github.com/NaturalIntelligence/strnum)
7
-
8
- ## Users
9
-
10
- <a href="https://github.com/aws-amplify" target="_blank"><img src="https://avatars.githubusercontent.com/u/41077760?s=100&v=4"></a>
11
- <a href="https://github.com/astrapay" target="_blank"><img src="https://avatars.githubusercontent.com/u/90901882?s=100&v=4"></a>
12
- <a href="https://github.com/process-analytics" target="_blank"><img src="https://avatars.githubusercontent.com/u/60110287?s=100&v=4"></a>
13
- <a href="https://github.com/NaturalIntelligence" target="_blank"><img src="https://avatars.githubusercontent.com/u/16322633?s=100&v=4"></a>
14
- Many React Native projects and plugins
15
-
16
- ## Usage
17
-
18
- ```bash
19
- npm install strnum
20
- ```
21
- ```js
22
- const toNumber = require("strnum");
23
-
24
- toNumber(undefined) // undefined
25
- toNumber(null)) //null
26
- toNumber("")) // ""
27
- toNumber("string"); //"string")
28
- toNumber("12,12"); //"12,12")
29
- toNumber("12 12"); //"12 12")
30
- toNumber("12-12"); //"12-12")
31
- toNumber("12.12.12"); //"12.12.12")
32
- toNumber("0x2f"); //47)
33
- toNumber("-0x2f"); //-47)
34
- toNumber("0x2f", { hex : true}); //47)
35
- toNumber("-0x2f", { hex : true}); //-47)
36
- toNumber("0x2f", { hex : false}); //"0x2f")
37
- toNumber("-0x2f", { hex : false}); //"-0x2f")
38
- toNumber("06"); //6)
39
- toNumber("06", { leadingZeros : true}); //6)
40
- toNumber("06", { leadingZeros : false}); //"06")
41
-
42
- toNumber("006"); //6)
43
- toNumber("006", { leadingZeros : true}); //6)
44
- toNumber("006", { leadingZeros : false}); //"006")
45
- toNumber("0.0"); //0)
46
- toNumber("00.00"); //0)
47
- toNumber("0.06"); //0.06)
48
- toNumber("00.6"); //0.6)
49
- toNumber(".006"); //0.006)
50
- toNumber("6.0"); //6)
51
- toNumber("06.0"); //6)
52
-
53
- toNumber("0.0", { leadingZeros : false}); //0)
54
- toNumber("00.00", { leadingZeros : false}); //"00.00")
55
- toNumber("0.06", { leadingZeros : false}); //0.06)
56
- toNumber("00.6", { leadingZeros : false}); //"00.6")
57
- toNumber(".006", { leadingZeros : false}); //0.006)
58
- toNumber("6.0" , { leadingZeros : false}); //6)
59
- toNumber("06.0" , { leadingZeros : false}); //"06.0")
60
- toNumber("-06"); //-6)
61
- toNumber("-06", { leadingZeros : true}); //-6)
62
- toNumber("-06", { leadingZeros : false}); //"-06")
63
-
64
- toNumber("-0.0"); //-0)
65
- toNumber("-00.00"); //-0)
66
- toNumber("-0.06"); //-0.06)
67
- toNumber("-00.6"); //-0.6)
68
- toNumber("-.006"); //-0.006)
69
- toNumber("-6.0"); //-6)
70
- toNumber("-06.0"); //-6)
71
-
72
- toNumber("-0.0" , { leadingZeros : false}); //-0)
73
- toNumber("-00.00", { leadingZeros : false}); //"-00.00")
74
- toNumber("-0.06", { leadingZeros : false}); //-0.06)
75
- toNumber("-00.6", { leadingZeros : false}); //"-00.6")
76
- toNumber("-.006", {leadingZeros : false}); //-0.006)
77
- toNumber("-6.0" , { leadingZeros : false}); //-6)
78
- toNumber("-06.0" , { leadingZeros : false}); //"-06.0")
79
- toNumber("420926189200190257681175017717") ; //4.209261892001902e+29)
80
- toNumber("000000000000000000000000017717" , { leadingZeros : false}); //"000000000000000000000000017717")
81
- toNumber("000000000000000000000000017717" , { leadingZeros : true}); //17717)
82
- toNumber("01.0e2" , { leadingZeros : false}); //"01.0e2")
83
- toNumber("-01.0e2" , { leadingZeros : false}); //"-01.0e2")
84
- toNumber("01.0e2") ; //100)
85
- toNumber("-01.0e2") ; //-100)
86
- toNumber("1.0e2") ; //100)
87
-
88
- toNumber("-1.0e2") ; //-100)
89
- toNumber("1.0e-2"); //0.01)
90
-
91
- toNumber("+1212121212"); // 1212121212
92
- toNumber("+1212121212", { skipLike: /\+[0-9]{10}/} )); //"+1212121212"
93
-
94
- toNumber("1e1000", { unicode: true, infinity: "original" }); //"1e1000"
95
- toNumber("1000", { unicode: true }); //1000
96
- toNumber("1000", { unicode: false }); //"1000"
97
- ```
98
-
99
- Supported Options
100
- ```js
101
- hex: true, //when hexadecimal string should be parsed
102
- leadingZeros: true, //when number with leading zeros like 08 should be parsed. 0.0 is not impacted
103
- eNotation: true, //when number with eNotation or number parsed in eNotation should be considered
104
- skipLike: /regex/ //when string should not be parsed when it matches the specified regular expression
105
- infinity: "original", // "null", "infinity" (Infinity type), "string" ("Infinity" (the string literal))
106
- unicode: false, //when number with unicode numerals should be parsed
107
- ```
108
-
109
-
110
- # Try out our other work
111
-
112
- WishIn - You need it if negative thoughts take over all the time <br>
113
- <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>
@@ -1,36 +0,0 @@
1
- {
2
- "name": "strnum",
3
- "version": "2.4.1",
4
- "description": "Parse String to Number based on configuration",
5
- "type": "module",
6
- "main": "strnum.js",
7
- "scripts": {
8
- "test": "jasmine tests/*_test.js"
9
- },
10
- "keywords": [
11
- "string",
12
- "number",
13
- "parse",
14
- "convert",
15
- "unicode"
16
- ],
17
- "repository": {
18
- "type": "git",
19
- "url": "https://github.com/NaturalIntelligence/strnum"
20
- },
21
- "author": "Amit Gupta (https://solothought.work/)",
22
- "license": "MIT",
23
- "funding": [
24
- {
25
- "type": "github",
26
- "url": "https://github.com/sponsors/NaturalIntelligence"
27
- }
28
- ],
29
- "devDependencies": {
30
- "@byspec/numbers": "^0.1.1",
31
- "jasmine": "^5.6.0"
32
- },
33
- "dependencies": {
34
- "anynum": "^1.0.1"
35
- }
36
- }
@@ -1,171 +0,0 @@
1
- const hexRegex = /^[-+]?0x[a-fA-F0-9]+$/;
2
- const binRegex = /^0b[01]+$/;
3
- const octRegex = /^0o[0-7]+$/;
4
- const numRegex = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/;
5
-
6
- import anynum from "anynum";
7
-
8
- const consider = {
9
- hex: true,
10
- binary: false,
11
- octal: false,
12
- leadingZeros: true,
13
- decimalPoint: "\.",
14
- eNotation: true,
15
- //skipLike: /regex/,
16
- infinity: "original", // "null", "infinity" (Infinity type), "string" ("Infinity" (the string literal))
17
- unicode: false,
18
- };
19
-
20
- export default function toNumber(str, options = {}) {
21
- options = Object.assign({}, consider, options);
22
- if (!str || typeof str !== "string") return str;
23
-
24
- let trimmedStr = str.trim();
25
-
26
- if (trimmedStr.length === 0) return str;
27
- else if (options.skipLike !== undefined && options.skipLike.test(trimmedStr)) return str;
28
- else if (trimmedStr === "0") return 0;
29
-
30
- if (options.unicode) {
31
- trimmedStr = anynum(trimmedStr);
32
- if (trimmedStr === "0") return 0; // re-check after normalization
33
- }
34
- if (options.hex && hexRegex.test(trimmedStr)) {
35
- return parse_int(trimmedStr, 16);
36
- } else if (options.binary && binRegex.test(trimmedStr)) {
37
- return parse_int(trimmedStr, 2);
38
- } else if (options.octal && octRegex.test(trimmedStr)) {
39
- return parse_int(trimmedStr, 8);
40
- } else if (!isFinite(trimmedStr)) { //Infinity
41
- return handleInfinity(str, Number(trimmedStr), options);
42
- } else if (trimmedStr.includes('e') || trimmedStr.includes('E')) { //eNotation
43
- return resolveEnotation(str, trimmedStr, options);
44
- } else {
45
- //separate negative sign, leading zeros, and rest number
46
- const match = numRegex.exec(trimmedStr);
47
- // +00.123 => [ , '+', '00', '.123', ..
48
- if (match) {
49
- const sign = match[1] || "";
50
- const leadingZeros = match[2];
51
- let numTrimmedByZeros = trimZeros(match[3]); //complete num without leading zeros
52
- const decimalAdjacentToLeadingZeros = sign ? // 0., -00., 000.
53
- str[leadingZeros.length + 1] === "."
54
- : str[leadingZeros.length] === ".";
55
-
56
- //trim ending zeros for floating number
57
- if (!options.leadingZeros //leading zeros are not allowed
58
- && (leadingZeros.length > 1
59
- || (leadingZeros.length === 1 && !decimalAdjacentToLeadingZeros))) {
60
- // 00, 00.3, +03.24, 03, 03.24
61
- return str;
62
- }
63
- else {//no leading zeros or leading zeros are allowed
64
- const num = Number(trimmedStr);
65
- const parsedStr = String(num);
66
-
67
- if (num === 0) return num;
68
- if (parsedStr.search(/[eE]/) !== -1) { //given number is long and parsed to eNotation
69
- if (options.eNotation) return num;
70
- else return str;
71
- } else if (trimmedStr.indexOf(".") !== -1) { //floating number
72
- if (parsedStr === "0") return num; //0.0
73
- else if (parsedStr === numTrimmedByZeros) return num; //0.456. 0.79000
74
- else if (parsedStr === `${sign}${numTrimmedByZeros}`) return num;
75
- else return str;
76
- }
77
-
78
- let n = leadingZeros ? numTrimmedByZeros : trimmedStr;
79
- if (leadingZeros) {
80
- // -009 => -9
81
- return (n === parsedStr) || (sign + n === parsedStr) ? num : str
82
- } else {
83
- // +9
84
- return (n === parsedStr) || (n === sign + parsedStr) ? num : str
85
- }
86
- }
87
- } else { //non-numeric string
88
- return str;
89
- }
90
- }
91
- }
92
-
93
- const eNotationRegx = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;
94
- function resolveEnotation(str, trimmedStr, options) {
95
- if (!options.eNotation) return str;
96
- const notation = trimmedStr.match(eNotationRegx);
97
- if (notation) {
98
- let sign = notation[1] || "";
99
- const eChar = notation[3].indexOf("e") === -1 ? "E" : "e";
100
- const leadingZeros = notation[2];
101
- const eAdjacentToLeadingZeros = sign ? // 0E.
102
- str[leadingZeros.length + 1] === eChar
103
- : str[leadingZeros.length] === eChar;
104
-
105
- if (leadingZeros.length > 1 && eAdjacentToLeadingZeros) return str;
106
- else if (leadingZeros.length === 1
107
- && (notation[3].startsWith(`.${eChar}`) || notation[3][0] === eChar)) {
108
- return Number(trimmedStr);
109
- } else if (leadingZeros.length > 0) {
110
- // Has leading zeros — only accept if leadingZeros option allows it
111
- if (options.leadingZeros && !eAdjacentToLeadingZeros) {
112
- trimmedStr = (notation[1] || "") + notation[3];
113
- return Number(trimmedStr);
114
- } else return str;
115
- } else {
116
- // No leading zeros — always valid e-notation, parse it
117
- return Number(trimmedStr);
118
- }
119
- } else {
120
- return str;
121
- }
122
- }
123
-
124
- /**
125
- *
126
- * @param {string} numStr without leading zeros
127
- * @returns
128
- */
129
- function trimZeros(numStr) {
130
- if (numStr && numStr.indexOf(".") !== -1) {//float
131
- numStr = numStr.replace(/0+$/, ""); //remove ending zeros
132
- if (numStr === ".") numStr = "0";
133
- else if (numStr[0] === ".") numStr = "0" + numStr;
134
- else if (numStr[numStr.length - 1] === ".") numStr = numStr.substring(0, numStr.length - 1);
135
- return numStr;
136
- }
137
- return numStr;
138
- }
139
-
140
- function parse_int(numStr, base) {
141
- const str = numStr.trim();
142
- if (base === 2 || base === 8) numStr = str.substring(2);
143
-
144
- if (parseInt) return parseInt(numStr, base);
145
- else if (Number.parseInt) return Number.parseInt(numStr, base);
146
- else if (window && window.parseInt) return window.parseInt(numStr, base);
147
- else throw new Error("parseInt, Number.parseInt, window.parseInt are not supported");
148
- }
149
-
150
- /**
151
- * Handle infinite values based on user option
152
- * @param {string} str - original input string
153
- * @param {number} num - parsed number (Infinity or -Infinity)
154
- * @param {object} options - user options
155
- * @returns {string|number|null} based on infinity option
156
- */
157
- function handleInfinity(str, num, options) {
158
- const isPositive = num === Infinity;
159
-
160
- switch (options.infinity.toLowerCase()) {
161
- case "null":
162
- return null;
163
- case "infinity":
164
- return num; // Return Infinity or -Infinity
165
- case "string":
166
- return isPositive ? "Infinity" : "-Infinity";
167
- case "original":
168
- default:
169
- return str; // Return original string like "1e1000"
170
- }
171
- }
@@ -1,189 +0,0 @@
1
- # xml-naming
2
-
3
- Validates XML name productions as defined in the [XML 1.0](https://www.w3.org/TR/xml/) and [XML 1.1](https://www.w3.org/TR/xml11/) specifications.
4
-
5
- Covers all five productions:
6
-
7
- | Production | Description | Colon | Digit/hyphen start |
8
- |---|---|---|---|
9
- | `Name` | General XML name | ✅ | ❌ |
10
- | `NCName` | Non-Colonized name | ❌ | ❌ |
11
- | `QName` | Namespace-qualified name (`prefix:local`) | ✅ (one only) | ❌ |
12
- | `NMToken` | Name token (relaxed start) | ✅ | ✅ |
13
- | `NMTokens` | Whitespace-separated NMToken list | ✅ | ✅ |
14
-
15
- Used internally by [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser), [fast-xml-validator](https://github.com/NaturalIntelligence/fast-xml-validator), [@nodable\flexible-xml-parser](https://github.com/nodable/flexible-xml-parser) and [fast-svg-parser](https://github.com/amitguptagwl/fast-svg-parser).
16
-
17
- ---
18
-
19
- ## Install
20
-
21
- ```bash
22
- npm install xml-naming
23
- ```
24
-
25
- ---
26
-
27
- ## Usage
28
-
29
- ### Boolean validators
30
-
31
- ```js
32
- import { name, ncName, qName, nmToken, nmTokens } from 'xml-naming';
33
-
34
- // Name — colon allowed anywhere, used for DOCTYPE entity names
35
- name('foo') // true
36
- name('a:b:c') // true ← multiple colons fine for Name
37
- name('1foo') // false ← digit start invalid
38
-
39
- // NCName — no colon, used for SVG id attributes, namespace prefixes
40
- ncName('my-id') // true
41
- ncName('xlink:href') // false ← colon not allowed
42
-
43
- // QName — exactly one colon as prefix separator, used for element/attribute names
44
- qName('svg:circle') // true
45
- qName('foo') // true ← unprefixed QName is valid
46
- qName('a:b:c') // false ← only one colon allowed
47
- qName(':foo') // false ← cannot start with colon
48
-
49
- // NMToken — any NameChar at start, used for DTD NMTOKEN attributes
50
- nmToken('123') // true ← digit start is fine
51
- nmToken('-bar') // true
52
- nmToken('foo bar') // false ← space not allowed
53
-
54
- // NMTokens — whitespace-separated NMToken list
55
- nmTokens('tok1 tok2 -foo 123') // true
56
- ```
57
-
58
- ### XML version option
59
-
60
- All validators accept an optional `{ xmlVersion }` option:
61
-
62
- ```js
63
- import { name } from 'xml-naming';
64
-
65
- name('\u0085', { xmlVersion: '1.0' }) // false — NEL (Next Line), not in 1.0 ranges
66
- name('\u0085', { xmlVersion: '1.1' }) // true — explicitly allowed in 1.1
67
-
68
- name('\uD800\uDC00', { xmlVersion: '1.0' }) // false
69
- name('\uD800\uDC00', { xmlVersion: '1.1' }) // true
70
- ```
71
-
72
- ---
73
-
74
- ### Diagnostic validation
75
-
76
- ```js
77
- import { validate } from 'xml-naming';
78
-
79
- validate('svg:circle', 'qName')
80
- // { valid: true, production: 'qName', input: 'svg:circle' }
81
-
82
- validate('1foo', 'ncName')
83
- // {
84
- // valid: false,
85
- // production: 'ncName',
86
- // input: '1foo',
87
- // reason: 'First character "1" is not a valid NameStartChar',
88
- // position: 0
89
- // }
90
-
91
- validate('foo:bar', 'ncName')
92
- // {
93
- // valid: false,
94
- // production: 'ncName',
95
- // input: 'foo:bar',
96
- // reason: 'Colon is not allowed in NCName',
97
- // position: 3
98
- // }
99
-
100
- validate('a:b:c', 'qName')
101
- // {
102
- // valid: false,
103
- // production: 'qName',
104
- // input: 'a:b:c',
105
- // reason: 'QName can have at most one colon',
106
- // position: 3
107
- // }
108
- ```
109
-
110
- ---
111
-
112
- ### Batch validation
113
-
114
- ```js
115
- import { validateAll } from 'xml-naming';
116
-
117
- validateAll(['svg', 'circle', '123bad', 'xlink:href'], 'ncName')
118
- // [
119
- // { valid: true, production: 'ncName', input: 'svg' },
120
- // { valid: true, production: 'ncName', input: 'circle' },
121
- // { valid: false, production: 'ncName', input: '123bad', reason: '...', position: 0 },
122
- // { valid: false, production: 'ncName', input: 'xlink:href',reason: '...', position: 5 }
123
- // ]
124
- ```
125
-
126
- ---
127
-
128
- ### Sanitize / auto-fix
129
-
130
- Useful when generating XML/SVG programmatically from user-supplied strings:
131
-
132
- ```js
133
- import { sanitize } from 'xml-naming';
134
-
135
- sanitize('123abc', 'ncName') // '_123abc' ← digit start fixed
136
- sanitize('my element','name') // 'my_element' ← space replaced
137
- sanitize('foo:bar', 'ncName') // 'foobar' ← colon stripped
138
- sanitize('hello!', 'name') // 'hello_' ← illegal char replaced
139
-
140
- // Custom replacement character
141
- sanitize('my element', 'name', { replacement: '-' }) // 'my-element'
142
- ```
143
-
144
- ---
145
-
146
- ## Which production should I use?
147
-
148
- | Context | Production |
149
- |---|---|
150
- | XML element/attribute names (namespace-aware) | `qName` |
151
- | SVG `id` attribute values | `ncName` |
152
- | Namespace prefix alone | `ncName` |
153
- | DOCTYPE `<!ENTITY name ...>` | `name` |
154
- | DOCTYPE `<!NOTATION name ...>` | `name` |
155
- | DTD `NMTOKEN` attribute values | `nmToken` |
156
- | DTD `NMTOKENS` attribute values | `nmTokens` |
157
-
158
- > **Note:** DOCTYPE entity and notation names must use `Name`, not `QName`. Colons carry no namespace meaning in the DTD subset.
159
-
160
- ---
161
-
162
- ## API
163
-
164
- ### `name(str, opts?)` → `boolean`
165
- ### `ncName(str, opts?)` → `boolean`
166
- ### `qName(str, opts?)` → `boolean`
167
- ### `nmToken(str, opts?)` → `boolean`
168
- ### `nmTokens(str, opts?)` → `boolean`
169
-
170
- `opts`:
171
- - `xmlVersion`: `'1.0'` (default) | `'1.1'`
172
-
173
- ### `validate(str, production, opts?)` → `ValidationResult`
174
-
175
- `production`: `'name'` | `'ncName'` | `'qName'` | `'nmToken'` | `'nmTokens'`
176
-
177
- ### `validateAll(strings[], production, opts?)` → `ValidationResult[]`
178
-
179
- ### `sanitize(str, production?, opts?)` → `string`
180
-
181
- `opts`:
182
- - `xmlVersion`: `'1.0'` | `'1.1'`
183
- - `replacement`: string (default `'_'`)
184
-
185
- ---
186
-
187
- ## License
188
-
189
- MIT
@@ -1,54 +0,0 @@
1
- {
2
- "name": "xml-naming",
3
- "version": "0.1.0",
4
- "description": "Validates XML name productions — Name, NCName, QName, NMToken, NMTokens — for XML 1.0 and 1.1",
5
- "type": "module",
6
- "main": "./src/index.js",
7
- "types": "./src/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "import": "./src/index.js",
11
- "types": "./src/index.d.ts"
12
- }
13
- },
14
- "files": [
15
- "src",
16
- "README.md"
17
- ],
18
- "scripts": {
19
- "test": "jasmine specs/*spec.js"
20
- },
21
- "keywords": [
22
- "xml",
23
- "xml-name",
24
- "ncname",
25
- "qname",
26
- "nmtoken",
27
- "xml-validation",
28
- "xml-namespace",
29
- "name-validator",
30
- "xml-1.0",
31
- "xml-1.1"
32
- ],
33
- "author": "Amit Gupta (https://solothought.com)",
34
- "license": "MIT",
35
- "funding": [
36
- {
37
- "type": "github",
38
- "url": "https://github.com/sponsors/NaturalIntelligence"
39
- }
40
- ],
41
- "devDependencies": {
42
- "jasmine": "^5.0.0"
43
- },
44
- "engines": {
45
- "node": ">=16.0.0"
46
- },
47
- "repository": {
48
- "type": "git",
49
- "url": "https://github.com/NaturalIntelligence/xml-naming"
50
- },
51
- "bugs": {
52
- "url": "https://github.com/NaturalIntelligence/xml-naming/issues"
53
- }
54
- }
@@ -1,74 +0,0 @@
1
- export interface ValidationOptions {
2
- /** XML specification version to validate against. Defaults to '1.0'. */
3
- xmlVersion?: '1.0' | '1.1';
4
- }
5
-
6
- export interface SanitizeOptions extends ValidationOptions {
7
- /** Character used to replace invalid characters. Defaults to '_'. */
8
- replacement?: string;
9
- }
10
-
11
- export type Production = 'name' | 'ncName' | 'qName' | 'nmToken' | 'nmTokens';
12
-
13
- export interface ValidationResult {
14
- valid: boolean;
15
- production: Production;
16
- input: string;
17
- /** Present only when valid is false. */
18
- reason?: string;
19
- /** Index of the first offending character. Present only when valid is false. */
20
- position?: number;
21
- }
22
-
23
- /**
24
- * Returns true if the string is a valid XML Name.
25
- * Colons are permitted anywhere (Name production).
26
- * Used for: DOCTYPE entity names, notation names, DTD element declarations.
27
- */
28
- export function name(str: string, opts?: ValidationOptions): boolean;
29
-
30
- /**
31
- * Returns true if the string is a valid NCName (Non-Colonized Name).
32
- * Colons are not permitted.
33
- * Used for: namespace prefixes, local names, SVG id attributes.
34
- */
35
- export function ncName(str: string, opts?: ValidationOptions): boolean;
36
-
37
- /**
38
- * Returns true if the string is a valid QName (Qualified Name).
39
- * Allows exactly one colon as a prefix separator: prefix:localName.
40
- * Used for: element and attribute names in namespace-aware XML/SVG.
41
- */
42
- export function qName(str: string, opts?: ValidationOptions): boolean;
43
-
44
- /**
45
- * Returns true if the string is a valid NMToken.
46
- * Same character set as Name but no restriction on the first character.
47
- * Used for: DTD NMTOKEN attribute values.
48
- */
49
- export function nmToken(str: string, opts?: ValidationOptions): boolean;
50
-
51
- /**
52
- * Returns true if the string is a valid NMTokens value.
53
- * A whitespace-separated list of NMToken values.
54
- * Used for: DTD NMTOKENS attribute values.
55
- */
56
- export function nmTokens(str: string, opts?: ValidationOptions): boolean;
57
-
58
- /**
59
- * Validates a string against a named XML production and returns a detailed result.
60
- */
61
- export function validate(str: string, production: Production, opts?: ValidationOptions): ValidationResult;
62
-
63
- /**
64
- * Validates an array of strings against a named XML production.
65
- */
66
- export function validateAll(strings: string[], production: Production, opts?: ValidationOptions): ValidationResult[];
67
-
68
- /**
69
- * Transforms an invalid string into the nearest valid XML name for the given production.
70
- * - Strips or replaces illegal characters
71
- * - Fixes invalid start characters by prepending the replacement character
72
- * - Removes colons for NCName production
73
- */
74
- export function sanitize(str: string, production?: Production, opts?: SanitizeOptions): string;