@mavogel/awscdk-rootmail 0.0.330 → 0.0.331

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 (171) hide show
  1. package/.jsii +3 -3
  2. package/lib/rootmail.js +1 -1
  3. package/lib/ses-receive.js +1 -1
  4. package/node_modules/@aws-sdk/client-cloudwatch-logs/package.json +16 -16
  5. package/node_modules/@aws-sdk/client-route-53/package.json +16 -16
  6. package/node_modules/@aws-sdk/client-s3/package.json +21 -21
  7. package/node_modules/@aws-sdk/client-ses/package.json +15 -15
  8. package/node_modules/@aws-sdk/client-ssm/package.json +15 -15
  9. package/node_modules/@aws-sdk/core/dist-cjs/index.js +54 -21
  10. package/node_modules/@aws-sdk/core/dist-cjs/submodules/protocols/index.js +54 -21
  11. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/ProtocolLib.js +24 -6
  12. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/cbor/AwsSmithyRpcV2CborProtocol.js +6 -5
  13. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsJson1_0Protocol.js +2 -1
  14. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsJson1_1Protocol.js +2 -1
  15. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsJsonRpcProtocol.js +6 -4
  16. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsRestJsonProtocol.js +6 -4
  17. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/query/AwsQueryProtocol.js +4 -2
  18. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/xml/AwsRestXmlProtocol.js +9 -3
  19. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/ProtocolLib.d.ts +13 -0
  20. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/cbor/AwsSmithyRpcV2CborProtocol.d.ts +3 -1
  21. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsJson1_0Protocol.d.ts +3 -1
  22. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsJson1_1Protocol.d.ts +3 -1
  23. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsJsonRpcProtocol.d.ts +3 -1
  24. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsRestJsonProtocol.d.ts +3 -1
  25. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/query/AwsEc2QueryProtocol.d.ts +3 -0
  26. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/query/AwsQueryProtocol.d.ts +3 -0
  27. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/xml/AwsRestXmlProtocol.d.ts +2 -0
  28. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/ProtocolLib.d.ts +6 -0
  29. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/cbor/AwsSmithyRpcV2CborProtocol.d.ts +3 -0
  30. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsJson1_0Protocol.d.ts +3 -0
  31. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsJson1_1Protocol.d.ts +3 -0
  32. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsJsonRpcProtocol.d.ts +3 -0
  33. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsRestJsonProtocol.d.ts +8 -1
  34. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/query/AwsEc2QueryProtocol.d.ts +3 -0
  35. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/query/AwsQueryProtocol.d.ts +3 -0
  36. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/xml/AwsRestXmlProtocol.d.ts +6 -1
  37. package/node_modules/@aws-sdk/core/package.json +4 -4
  38. package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
  39. package/node_modules/@aws-sdk/credential-provider-http/package.json +5 -5
  40. package/node_modules/@aws-sdk/credential-provider-ini/package.json +9 -9
  41. package/node_modules/@aws-sdk/credential-provider-login/package.json +3 -3
  42. package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
  43. package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
  44. package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
  45. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
  46. package/node_modules/@aws-sdk/middleware-flexible-checksums/package.json +4 -4
  47. package/node_modules/@aws-sdk/middleware-sdk-s3/package.json +5 -5
  48. package/node_modules/@aws-sdk/middleware-user-agent/package.json +3 -3
  49. package/node_modules/@aws-sdk/nested-clients/package.json +14 -14
  50. package/node_modules/@aws-sdk/region-config-resolver/package.json +2 -2
  51. package/node_modules/@aws-sdk/signature-v4-multi-region/package.json +2 -2
  52. package/node_modules/@aws-sdk/token-providers/package.json +3 -3
  53. package/node_modules/@aws-sdk/util-user-agent-node/package.json +2 -2
  54. package/node_modules/@aws-sdk/xml-builder/dist-cjs/index.js +21 -11
  55. package/node_modules/@aws-sdk/xml-builder/dist-cjs/xml-parser.js +5 -1
  56. package/node_modules/@aws-sdk/xml-builder/dist-es/escape-attribute.js +8 -1
  57. package/node_modules/@aws-sdk/xml-builder/dist-es/escape-element.js +13 -10
  58. package/node_modules/@aws-sdk/xml-builder/dist-es/xml-parser.js +5 -1
  59. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/CHANGELOG.md +40 -4
  60. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/README.md +8 -7
  61. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxbuilder.min.js +1 -1
  62. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxbuilder.min.js.map +1 -1
  63. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.cjs +1 -1
  64. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.d.cts +82 -20
  65. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.min.js +1 -1
  66. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.min.js.map +1 -1
  67. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxparser.min.js +1 -1
  68. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxparser.min.js.map +1 -1
  69. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxvalidator.min.js.map +1 -1
  70. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/pem.d.cts +148 -0
  71. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/package.json +4 -3
  72. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/fxp.d.ts +75 -19
  73. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/pem.d.ts +135 -0
  74. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/util.js +18 -0
  75. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js +37 -18
  76. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js +76 -5
  77. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js +298 -116
  78. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/XMLParser.js +2 -2
  79. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/node2json.js +65 -15
  80. package/node_modules/@aws-sdk/xml-builder/package.json +2 -2
  81. package/node_modules/@smithy/config-resolver/dist-cjs/index.js +12 -0
  82. package/node_modules/@smithy/config-resolver/dist-es/endpointsConfig/NodeUseDualstackEndpointConfigOptions.js +5 -0
  83. package/node_modules/@smithy/config-resolver/dist-es/endpointsConfig/NodeUseFipsEndpointConfigOptions.js +5 -0
  84. package/node_modules/@smithy/config-resolver/dist-types/endpointsConfig/NodeUseDualstackEndpointConfigOptions.d.ts +6 -0
  85. package/node_modules/@smithy/config-resolver/dist-types/endpointsConfig/NodeUseFipsEndpointConfigOptions.d.ts +6 -0
  86. package/node_modules/@smithy/config-resolver/dist-types/ts3.4/endpointsConfig/NodeUseDualstackEndpointConfigOptions.d.ts +6 -0
  87. package/node_modules/@smithy/config-resolver/dist-types/ts3.4/endpointsConfig/NodeUseFipsEndpointConfigOptions.d.ts +6 -0
  88. package/node_modules/@smithy/config-resolver/package.json +1 -1
  89. package/node_modules/@smithy/middleware-endpoint/dist-types/resolveEndpointConfig.d.ts +2 -2
  90. package/node_modules/@smithy/middleware-endpoint/dist-types/ts3.4/resolveEndpointConfig.d.ts +2 -2
  91. package/node_modules/@smithy/middleware-endpoint/package.json +1 -1
  92. package/node_modules/@smithy/middleware-retry/package.json +2 -2
  93. package/node_modules/@smithy/smithy-client/package.json +2 -2
  94. package/node_modules/@smithy/util-defaults-mode-browser/package.json +2 -2
  95. package/node_modules/@smithy/util-defaults-mode-node/package.json +3 -3
  96. package/node_modules/fast-xml-builder/CHANGELOG.md +16 -0
  97. package/node_modules/fast-xml-builder/README.md +1 -1
  98. package/node_modules/fast-xml-builder/lib/fxb.cjs +1 -0
  99. package/node_modules/fast-xml-builder/lib/fxb.d.cts +22 -9
  100. package/node_modules/fast-xml-builder/lib/fxb.min.js +2 -0
  101. package/node_modules/fast-xml-builder/lib/fxb.min.js.map +1 -0
  102. package/node_modules/fast-xml-builder/package.json +7 -5
  103. package/node_modules/fast-xml-builder/src/fxb.d.ts +27 -3
  104. package/node_modules/fast-xml-builder/src/fxb.js +265 -21
  105. package/node_modules/fast-xml-builder/src/orderedJs2Xml.js +165 -18
  106. package/node_modules/mailparser/.release-please-manifest.json +1 -1
  107. package/node_modules/mailparser/CHANGELOG.md +7 -0
  108. package/node_modules/mailparser/package.json +3 -3
  109. package/node_modules/nodemailer/CHANGELOG.md +10 -0
  110. package/node_modules/nodemailer/lib/addressparser/index.js +68 -83
  111. package/node_modules/nodemailer/lib/base64/index.js +6 -5
  112. package/node_modules/nodemailer/lib/dkim/index.js +8 -16
  113. package/node_modules/nodemailer/lib/dkim/message-parser.js +12 -13
  114. package/node_modules/nodemailer/lib/dkim/relaxed-body.js +2 -2
  115. package/node_modules/nodemailer/lib/dkim/sign.js +13 -14
  116. package/node_modules/nodemailer/lib/errors.js +4 -7
  117. package/node_modules/nodemailer/lib/fetch/cookies.js +13 -18
  118. package/node_modules/nodemailer/lib/fetch/index.js +12 -15
  119. package/node_modules/nodemailer/lib/json-transport/index.js +4 -4
  120. package/node_modules/nodemailer/lib/mail-composer/index.js +86 -116
  121. package/node_modules/nodemailer/lib/mailer/index.js +26 -26
  122. package/node_modules/nodemailer/lib/mailer/mail-message.js +17 -21
  123. package/node_modules/nodemailer/lib/mime-funcs/index.js +25 -40
  124. package/node_modules/nodemailer/lib/mime-funcs/mime-types.js +7 -11
  125. package/node_modules/nodemailer/lib/mime-node/index.js +81 -72
  126. package/node_modules/nodemailer/lib/mime-node/last-newline.js +1 -1
  127. package/node_modules/nodemailer/lib/mime-node/le-unix.js +4 -7
  128. package/node_modules/nodemailer/lib/mime-node/le-windows.js +1 -4
  129. package/node_modules/nodemailer/lib/nodemailer.js +11 -18
  130. package/node_modules/nodemailer/lib/qp/index.js +24 -21
  131. package/node_modules/nodemailer/lib/sendmail-transport/index.js +30 -41
  132. package/node_modules/nodemailer/lib/ses-transport/index.js +23 -34
  133. package/node_modules/nodemailer/lib/shared/index.js +94 -140
  134. package/node_modules/nodemailer/lib/smtp-connection/data-stream.js +3 -6
  135. package/node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js +11 -13
  136. package/node_modules/nodemailer/lib/smtp-connection/index.js +114 -181
  137. package/node_modules/nodemailer/lib/smtp-pool/index.js +20 -32
  138. package/node_modules/nodemailer/lib/smtp-pool/pool-resource.js +8 -12
  139. package/node_modules/nodemailer/lib/smtp-transport/index.js +22 -42
  140. package/node_modules/nodemailer/lib/stream-transport/index.js +7 -7
  141. package/node_modules/nodemailer/lib/well-known/index.js +7 -7
  142. package/node_modules/nodemailer/lib/xoauth2/index.js +22 -28
  143. package/node_modules/nodemailer/package.json +4 -3
  144. package/node_modules/path-expression-matcher/LICENSE +21 -0
  145. package/node_modules/path-expression-matcher/README.md +720 -0
  146. package/node_modules/path-expression-matcher/lib/pem.cjs +1 -0
  147. package/node_modules/path-expression-matcher/lib/pem.d.cts +523 -0
  148. package/node_modules/path-expression-matcher/lib/pem.min.js +2 -0
  149. package/node_modules/path-expression-matcher/lib/pem.min.js.map +1 -0
  150. package/node_modules/path-expression-matcher/package.json +78 -0
  151. package/node_modules/path-expression-matcher/src/Expression.js +232 -0
  152. package/node_modules/path-expression-matcher/src/Matcher.js +498 -0
  153. package/node_modules/path-expression-matcher/src/index.d.ts +518 -0
  154. package/node_modules/path-expression-matcher/src/index.js +28 -0
  155. package/node_modules/{@aws-sdk/xml-builder/node_modules/strnum → strnum}/CHANGELOG.md +9 -2
  156. package/node_modules/{@aws-sdk/xml-builder/node_modules/strnum → strnum}/README.md +1 -0
  157. package/node_modules/{@aws-sdk/xml-builder/node_modules/strnum → strnum}/package.json +3 -3
  158. package/node_modules/strnum/strnum.js +161 -0
  159. package/node_modules/strnum/tests/infinity_test.js +18 -0
  160. package/node_modules/{@aws-sdk/xml-builder/node_modules/strnum/strnum.test.js → strnum/tests/strnum_test.js} +70 -68
  161. package/node_modules/strnum/tests/temp.js +8 -0
  162. package/package.json +1 -1
  163. package/node_modules/@aws-sdk/xml-builder/node_modules/strnum/strnum.js +0 -129
  164. package/node_modules/@aws-sdk/xml-builder/node_modules/strnum/test.js +0 -9
  165. package/node_modules/fast-xml-builder/lib/builder.cjs +0 -1
  166. package/node_modules/fast-xml-builder/lib/builder.min.js +0 -2
  167. package/node_modules/fast-xml-builder/lib/builder.min.js.map +0 -1
  168. /package/node_modules/{@aws-sdk/xml-builder/node_modules/strnum → strnum}/.github/SECURITY.md +0 -0
  169. /package/node_modules/{@aws-sdk/xml-builder/node_modules/strnum → strnum}/.vscode/launch.json +0 -0
  170. /package/node_modules/{@aws-sdk/xml-builder/node_modules/strnum → strnum}/LICENSE +0 -0
  171. /package/node_modules/{@aws-sdk/xml-builder/node_modules/strnum → strnum}/algo.stflow +0 -0
@@ -0,0 +1,161 @@
1
+ const hexRegex = /^[-+]?0x[a-fA-F0-9]+$/;
2
+ const numRegex = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/;
3
+ // const octRegex = /^0x[a-z0-9]+/;
4
+ // const binRegex = /0x[a-z0-9]+/;
5
+
6
+
7
+ const consider = {
8
+ hex: true,
9
+ // oct: false,
10
+ leadingZeros: true,
11
+ decimalPoint: "\.",
12
+ eNotation: true,
13
+ //skipLike: /regex/,
14
+ infinity: "original", // "null", "infinity" (Infinity type), "string" ("Infinity" (the string literal))
15
+ };
16
+
17
+ export default function toNumber(str, options = {}) {
18
+ options = Object.assign({}, consider, options);
19
+ if (!str || typeof str !== "string") return str;
20
+
21
+ let trimmedStr = str.trim();
22
+
23
+ if (trimmedStr.length === 0) return str;
24
+ else if (options.skipLike !== undefined && options.skipLike.test(trimmedStr)) return str;
25
+ else if (trimmedStr === "0") return 0;
26
+ else if (options.hex && hexRegex.test(trimmedStr)) {
27
+ return parse_int(trimmedStr, 16);
28
+ // }else if (options.oct && octRegex.test(str)) {
29
+ // return Number.parseInt(val, 8);
30
+ } else if (!isFinite(trimmedStr)) { //Infinity
31
+ return handleInfinity(str, Number(trimmedStr), options);
32
+ } else if (trimmedStr.includes('e') || trimmedStr.includes('E')) { //eNotation
33
+ return resolveEnotation(str, trimmedStr, options);
34
+ // }else if (options.parseBin && binRegex.test(str)) {
35
+ // return Number.parseInt(val, 2);
36
+ } else {
37
+ //separate negative sign, leading zeros, and rest number
38
+ const match = numRegex.exec(trimmedStr);
39
+ // +00.123 => [ , '+', '00', '.123', ..
40
+ if (match) {
41
+ const sign = match[1] || "";
42
+ const leadingZeros = match[2];
43
+ let numTrimmedByZeros = trimZeros(match[3]); //complete num without leading zeros
44
+ const decimalAdjacentToLeadingZeros = sign ? // 0., -00., 000.
45
+ str[leadingZeros.length + 1] === "."
46
+ : str[leadingZeros.length] === ".";
47
+
48
+ //trim ending zeros for floating number
49
+ if (!options.leadingZeros //leading zeros are not allowed
50
+ && (leadingZeros.length > 1
51
+ || (leadingZeros.length === 1 && !decimalAdjacentToLeadingZeros))) {
52
+ // 00, 00.3, +03.24, 03, 03.24
53
+ return str;
54
+ }
55
+ else {//no leading zeros or leading zeros are allowed
56
+ const num = Number(trimmedStr);
57
+ const parsedStr = String(num);
58
+
59
+ if (num === 0) return num;
60
+ if (parsedStr.search(/[eE]/) !== -1) { //given number is long and parsed to eNotation
61
+ if (options.eNotation) return num;
62
+ else return str;
63
+ } else if (trimmedStr.indexOf(".") !== -1) { //floating number
64
+ if (parsedStr === "0") return num; //0.0
65
+ else if (parsedStr === numTrimmedByZeros) return num; //0.456. 0.79000
66
+ else if (parsedStr === `${sign}${numTrimmedByZeros}`) return num;
67
+ else return str;
68
+ }
69
+
70
+ let n = leadingZeros ? numTrimmedByZeros : trimmedStr;
71
+ if (leadingZeros) {
72
+ // -009 => -9
73
+ return (n === parsedStr) || (sign + n === parsedStr) ? num : str
74
+ } else {
75
+ // +9
76
+ return (n === parsedStr) || (n === sign + parsedStr) ? num : str
77
+ }
78
+ }
79
+ } else { //non-numeric string
80
+ return str;
81
+ }
82
+ }
83
+ }
84
+
85
+ const eNotationRegx = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;
86
+ function resolveEnotation(str, trimmedStr, options) {
87
+ if (!options.eNotation) return str;
88
+ const notation = trimmedStr.match(eNotationRegx);
89
+ if (notation) {
90
+ let sign = notation[1] || "";
91
+ const eChar = notation[3].indexOf("e") === -1 ? "E" : "e";
92
+ const leadingZeros = notation[2];
93
+ const eAdjacentToLeadingZeros = sign ? // 0E.
94
+ str[leadingZeros.length + 1] === eChar
95
+ : str[leadingZeros.length] === eChar;
96
+
97
+ if (leadingZeros.length > 1 && eAdjacentToLeadingZeros) return str;
98
+ else if (leadingZeros.length === 1
99
+ && (notation[3].startsWith(`.${eChar}`) || notation[3][0] === eChar)) {
100
+ return Number(trimmedStr);
101
+ } else if (leadingZeros.length > 0) {
102
+ // Has leading zeros — only accept if leadingZeros option allows it
103
+ if (options.leadingZeros && !eAdjacentToLeadingZeros) {
104
+ trimmedStr = (notation[1] || "") + notation[3];
105
+ return Number(trimmedStr);
106
+ } else return str;
107
+ } else {
108
+ // No leading zeros — always valid e-notation, parse it
109
+ return Number(trimmedStr);
110
+ }
111
+ } else {
112
+ return str;
113
+ }
114
+ }
115
+
116
+ /**
117
+ *
118
+ * @param {string} numStr without leading zeros
119
+ * @returns
120
+ */
121
+ function trimZeros(numStr) {
122
+ if (numStr && numStr.indexOf(".") !== -1) {//float
123
+ numStr = numStr.replace(/0+$/, ""); //remove ending zeros
124
+ if (numStr === ".") numStr = "0";
125
+ else if (numStr[0] === ".") numStr = "0" + numStr;
126
+ else if (numStr[numStr.length - 1] === ".") numStr = numStr.substring(0, numStr.length - 1);
127
+ return numStr;
128
+ }
129
+ return numStr;
130
+ }
131
+
132
+ function parse_int(numStr, base) {
133
+ //polyfill
134
+ if (parseInt) return parseInt(numStr, base);
135
+ else if (Number.parseInt) return Number.parseInt(numStr, base);
136
+ else if (window && window.parseInt) return window.parseInt(numStr, base);
137
+ else throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")
138
+ }
139
+
140
+ /**
141
+ * Handle infinite values based on user option
142
+ * @param {string} str - original input string
143
+ * @param {number} num - parsed number (Infinity or -Infinity)
144
+ * @param {object} options - user options
145
+ * @returns {string|number|null} based on infinity option
146
+ */
147
+ function handleInfinity(str, num, options) {
148
+ const isPositive = num === Infinity;
149
+
150
+ switch (options.infinity.toLowerCase()) {
151
+ case "null":
152
+ return null;
153
+ case "infinity":
154
+ return num; // Return Infinity or -Infinity
155
+ case "string":
156
+ return isPositive ? "Infinity" : "-Infinity";
157
+ case "original":
158
+ default:
159
+ return str; // Return original string like "1e1000"
160
+ }
161
+ }
@@ -0,0 +1,18 @@
1
+ import toNumber from "../strnum.js";
2
+
3
+ describe("Should convert all the valid numeric strings to number", () => {
4
+ it("should return infinity as per user option", () => {
5
+ expect(toNumber("1e1000", { infinity: "original" })).toEqual("1e1000");
6
+ expect(toNumber("1e1000", { infinity: "null" })).toEqual(null);
7
+ expect(toNumber("1e1000", { infinity: "infinity" })).toEqual(Infinity);
8
+ expect(toNumber("1e1000", { infinity: "string" })).toEqual("Infinity");
9
+ expect(toNumber("-1e1000", { infinity: "original" })).toEqual("-1e1000");
10
+ expect(toNumber("-1e1000", { infinity: "null" })).toEqual(null);
11
+ expect(toNumber("-1e1000", { infinity: "infinity" })).toEqual(-Infinity);
12
+ expect(toNumber("-1e1000", { infinity: "string" })).toEqual("-Infinity");
13
+
14
+
15
+ expect(toNumber("1e309")).toEqual("1e309");
16
+
17
+ });
18
+ });
@@ -1,13 +1,13 @@
1
- import toNumber from "./strnum.js";
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", () => {
5
5
  expect(toNumber(undefined)).not.toBeDefined();
6
6
  expect(toNumber(null)).toEqual(null);
7
7
  expect(toNumber("")).toEqual("");
8
+ expect(toNumber(" ")).toEqual(" ");
8
9
  expect(toNumber("string")).toEqual("string");
9
10
  expect(toNumber("e89794659669cb7bb967db73a7ea6889c3891727")).toEqual("e89794659669cb7bb967db73a7ea6889c3891727");
10
-
11
11
  });
12
12
  it("should not parse number with spaces or comma", () => {
13
13
  expect(toNumber("12,12")).toEqual("12,12");
@@ -24,10 +24,10 @@ describe("Should convert all the valid numeric strings to number", () => {
24
24
  it("should parse hexadecimal values", () => {
25
25
  expect(toNumber("0x2f")).toEqual(47);
26
26
  expect(toNumber("-0x2f")).toEqual(-47);
27
- expect(toNumber("0x2f", { hex : true})).toEqual(47);
28
- expect(toNumber("-0x2f", { hex : true})).toEqual(-47);
29
- expect(toNumber("0x2f", { hex : false})).toEqual("0x2f");
30
- expect(toNumber("-0x2f", { hex : false})).toEqual("-0x2f");
27
+ expect(toNumber("0x2f", { hex: true })).toEqual(47);
28
+ expect(toNumber("-0x2f", { hex: true })).toEqual(-47);
29
+ expect(toNumber("0x2f", { hex: false })).toEqual("0x2f");
30
+ expect(toNumber("-0x2f", { hex: false })).toEqual("-0x2f");
31
31
  })
32
32
  it("should not parse strings with 0x embedded", () => {
33
33
  expect(toNumber("0xzz")).toEqual("0xzz");
@@ -40,54 +40,54 @@ describe("Should convert all the valid numeric strings to number", () => {
40
40
  expect(toNumber("00")).toEqual(0);
41
41
  expect(toNumber("00.0")).toEqual(0);
42
42
 
43
- expect(toNumber("0",{ leadingZeros : false})).toEqual(0);
44
- expect(toNumber("00",{ leadingZeros : false})).toEqual("00");
45
- expect(toNumber("00.0",{ leadingZeros : false})).toEqual("00.0");
43
+ expect(toNumber("0", { leadingZeros: false })).toEqual(0);
44
+ expect(toNumber("00", { leadingZeros: false })).toEqual("00");
45
+ expect(toNumber("00.0", { leadingZeros: false })).toEqual("00.0");
46
46
 
47
47
  expect(toNumber("06")).toEqual(6);
48
- expect(toNumber("06", { leadingZeros : true})).toEqual(6);
49
- expect(toNumber("06", { leadingZeros : false})).toEqual("06");
48
+ expect(toNumber("06", { leadingZeros: true })).toEqual(6);
49
+ expect(toNumber("06", { leadingZeros: false })).toEqual("06");
50
50
 
51
51
  expect(toNumber("006")).toEqual(6);
52
- expect(toNumber("006", { leadingZeros : true})).toEqual(6);
53
- expect(toNumber("006", { leadingZeros : false})).toEqual("006");
52
+ expect(toNumber("006", { leadingZeros: true })).toEqual(6);
53
+ expect(toNumber("006", { leadingZeros: false })).toEqual("006");
54
54
 
55
- expect(toNumber("000000000000000000000000017717" , { leadingZeros : false})).toEqual("000000000000000000000000017717");
56
- expect(toNumber("000000000000000000000000017717" , { leadingZeros : true})).toEqual(17717);
57
- expect(toNumber("020211201030005811824") ).toEqual("020211201030005811824");
58
- expect(toNumber("0420926189200190257681175017717") ).toEqual(4.209261892001902e+29);
55
+ expect(toNumber("000000000000000000000000017717", { leadingZeros: false })).toEqual("000000000000000000000000017717");
56
+ expect(toNumber("000000000000000000000000017717", { leadingZeros: true })).toEqual(17717);
57
+ expect(toNumber("020211201030005811824")).toEqual("020211201030005811824");
58
+ expect(toNumber("0420926189200190257681175017717")).toEqual(4.209261892001902e+29);
59
59
  })
60
60
  it("invalid floating number", () => {
61
- expect(toNumber("20.21.030") ).toEqual("20.21.030");
62
- expect(toNumber("0.21.030") ).toEqual("0.21.030");
63
- expect(toNumber("0.21.") ).toEqual("0.21.");
61
+ expect(toNumber("20.21.030")).toEqual("20.21.030");
62
+ expect(toNumber("0.21.030")).toEqual("0.21.030");
63
+ expect(toNumber("0.21.")).toEqual("0.21.");
64
64
  });
65
65
  it("floating point and leading zeros", () => {
66
66
  expect(toNumber("0.")).toEqual(0);
67
67
  expect(toNumber("+0.")).toEqual(0);
68
68
  expect(toNumber("-0.")).toEqual(-0);
69
- expect(toNumber("1.") ).toEqual(1);
69
+ expect(toNumber("1.")).toEqual(1);
70
70
  expect(toNumber("00.00")).toEqual(0);
71
71
  expect(toNumber("0.06")).toEqual(0.06);
72
72
  expect(toNumber("00.6")).toEqual(0.6);
73
73
  expect(toNumber(".006")).toEqual(0.006);
74
74
  expect(toNumber("6.0")).toEqual(6);
75
75
  expect(toNumber("06.0")).toEqual(6);
76
-
77
- expect(toNumber("0.0", { leadingZeros : false})).toEqual(0);
78
- expect(toNumber("00.00", { leadingZeros : false})).toEqual("00.00");
79
- expect(toNumber("0.06", { leadingZeros : false})).toEqual(0.06);
80
- expect(toNumber("00.6", { leadingZeros : false})).toEqual("00.6");
81
- expect(toNumber(".006", { leadingZeros : false})).toEqual(0.006);
82
- expect(toNumber("6.0" , { leadingZeros : false})).toEqual(6);
83
- expect(toNumber("06.0" , { leadingZeros : false})).toEqual("06.0");
76
+
77
+ expect(toNumber("0.0", { leadingZeros: false })).toEqual(0);
78
+ expect(toNumber("00.00", { leadingZeros: false })).toEqual("00.00");
79
+ expect(toNumber("0.06", { leadingZeros: false })).toEqual(0.06);
80
+ expect(toNumber("00.6", { leadingZeros: false })).toEqual("00.6");
81
+ expect(toNumber(".006", { leadingZeros: false })).toEqual(0.006);
82
+ expect(toNumber("6.0", { leadingZeros: false })).toEqual(6);
83
+ expect(toNumber("06.0", { leadingZeros: false })).toEqual("06.0");
84
84
  })
85
85
  it("negative number leading zeros", () => {
86
86
  expect(toNumber("+06")).toEqual(6);
87
87
  expect(toNumber("-06")).toEqual(-6);
88
- expect(toNumber("-06", { leadingZeros : true})).toEqual(-6);
89
- expect(toNumber("-06", { leadingZeros : false})).toEqual("-06");
90
-
88
+ expect(toNumber("-06", { leadingZeros: true })).toEqual(-6);
89
+ expect(toNumber("-06", { leadingZeros: false })).toEqual("-06");
90
+
91
91
  expect(toNumber("-0.0")).toEqual(-0);
92
92
  expect(toNumber("-00.00")).toEqual(-0);
93
93
  expect(toNumber("-0.06")).toEqual(-0.06);
@@ -96,47 +96,49 @@ describe("Should convert all the valid numeric strings to number", () => {
96
96
  expect(toNumber("-6.0")).toEqual(-6);
97
97
  expect(toNumber("-06.0")).toEqual(-6);
98
98
  expect(toNumber("+06.0")).toEqual(6);
99
-
100
- expect(toNumber("-0.0" , { leadingZeros : false})).toEqual(-0);
101
- expect(toNumber("-00.00", { leadingZeros : false})).toEqual("-00.00");
102
- expect(toNumber("-0.06", { leadingZeros : false})).toEqual(-0.06);
103
- expect(toNumber("-00.6", { leadingZeros : false})).toEqual("-00.6");
104
- expect(toNumber("-.006", {leadingZeros : false})).toEqual(-0.006);
105
- expect(toNumber("-6.0" , { leadingZeros : false})).toEqual(-6);
106
- expect(toNumber("-06.0" , { leadingZeros : false})).toEqual("-06.0");
99
+
100
+ expect(toNumber("-0.0", { leadingZeros: false })).toEqual(-0);
101
+ expect(toNumber("-00.00", { leadingZeros: false })).toEqual("-00.00");
102
+ expect(toNumber("-0.06", { leadingZeros: false })).toEqual(-0.06);
103
+ expect(toNumber("-00.6", { leadingZeros: false })).toEqual("-00.6");
104
+ expect(toNumber("-.006", { leadingZeros: false })).toEqual(-0.006);
105
+ expect(toNumber("-6.0", { leadingZeros: false })).toEqual(-6);
106
+ expect(toNumber("-06.0", { leadingZeros: false })).toEqual("-06.0");
107
107
  })
108
108
  it("long number", () => {
109
- expect(toNumber("020211201030005811824") ).toEqual("020211201030005811824");
110
- expect(toNumber("20211201030005811824") ).toEqual("20211201030005811824");
111
- expect(toNumber("20.211201030005811824") ).toEqual("20.211201030005811824");
112
- expect(toNumber("0.211201030005811824") ).toEqual("0.211201030005811824");
109
+ expect(toNumber("020211201030005811824")).toEqual("020211201030005811824");
110
+ expect(toNumber("20211201030005811824")).toEqual("20211201030005811824");
111
+ expect(toNumber("20.211201030005811824")).toEqual("20.211201030005811824");
112
+ expect(toNumber("0.211201030005811824")).toEqual("0.211201030005811824");
113
113
  });
114
114
  it("scientific notation", () => {
115
- expect(toNumber("01.0e2" , { leadingZeros : false})).toEqual("01.0e2");
116
- expect(toNumber("-01.0e2" , { leadingZeros : false})).toEqual("-01.0e2");
117
- expect(toNumber("01.0e2") ).toEqual(100);
118
- expect(toNumber("-01.0e2") ).toEqual(-100);
119
- expect(toNumber("1.0e2") ).toEqual(100);
115
+ expect(toNumber("01.0e2", { leadingZeros: false })).toEqual("01.0e2");
116
+ expect(toNumber("-01.0e2", { leadingZeros: false })).toEqual("-01.0e2");
117
+ expect(toNumber("01.0e2")).toEqual(100);
118
+ expect(toNumber("-01.0e2")).toEqual(-100);
119
+ expect(toNumber("1.0e2")).toEqual(100);
120
120
 
121
- expect(toNumber("-1.0e2") ).toEqual(-100);
121
+ expect(toNumber("-1.0e2")).toEqual(-100);
122
122
  expect(toNumber("1.0e-2")).toEqual(0.01);
123
-
124
- expect(toNumber("420926189200190257681175017717") ).toEqual(4.209261892001902e+29);
125
- expect(toNumber("420926189200190257681175017717" , { eNotation: false} )).toEqual("420926189200190257681175017717");
126
-
123
+
124
+ expect(toNumber("420926189200190257681175017717")).toEqual(4.209261892001902e+29);
125
+ expect(toNumber("420926189200190257681175017717", { eNotation: false })).toEqual("420926189200190257681175017717");
126
+
127
127
  expect(toNumber("1e-2")).toEqual(0.01);
128
128
  expect(toNumber("1e+2")).toEqual(100);
129
129
  expect(toNumber("1.e+2")).toEqual(100);
130
+
131
+ expect(toNumber("1.5e3", { leadingZeros: false })).toEqual(1500);
130
132
  });
131
133
 
132
134
  it("scientific notation with upper E", () => {
133
- expect(toNumber("01.0E2" , { leadingZeros : false})).toEqual("01.0E2");
134
- expect(toNumber("-01.0E2" , { leadingZeros : false})).toEqual("-01.0E2");
135
- expect(toNumber("01.0E2") ).toEqual(100);
136
- expect(toNumber("-01.0E2") ).toEqual(-100);
137
- expect(toNumber("1.0E2") ).toEqual(100);
135
+ expect(toNumber("01.0E2", { leadingZeros: false })).toEqual("01.0E2");
136
+ expect(toNumber("-01.0E2", { leadingZeros: false })).toEqual("-01.0E2");
137
+ expect(toNumber("01.0E2")).toEqual(100);
138
+ expect(toNumber("-01.0E2")).toEqual(-100);
139
+ expect(toNumber("1.0E2")).toEqual(100);
138
140
 
139
- expect(toNumber("-1.0E2") ).toEqual(-100);
141
+ expect(toNumber("-1.0E2")).toEqual(-100);
140
142
  expect(toNumber("1.0E-2")).toEqual(0.01);
141
143
 
142
144
  expect(toNumber("E-2")).toEqual("E-2");
@@ -144,16 +146,16 @@ describe("Should convert all the valid numeric strings to number", () => {
144
146
  expect(toNumber("0E2")).toEqual(0);
145
147
  expect(toNumber("-0E2")).toEqual(-0);
146
148
  expect(toNumber("00E2")).toEqual("00E2");
147
- expect(toNumber("00E2", { leadingZeros : false})).toEqual("00E2");
149
+ expect(toNumber("00E2", { leadingZeros: false })).toEqual("00E2");
148
150
  });
149
-
151
+
150
152
  it("should skip matching pattern", () => {
151
153
  expect(toNumber("0", { skipLike: /.*/ })).toEqual("0");
152
- expect(toNumber("+12", { skipLike: /\+[0-9]{10}/} )).toEqual(12);
153
- expect(toNumber("12+12", { skipLike: /\+[0-9]{10}/} )).toEqual("12+12");
154
- expect(toNumber("12+1212121212", { skipLike: /\+[0-9]{10}/} )).toEqual("12+1212121212");
155
- expect(toNumber("+1212121212") ).toEqual(1212121212);
156
- expect(toNumber("+1212121212", { skipLike: /\+[0-9]{10}/} )).toEqual("+1212121212");
154
+ expect(toNumber("+12", { skipLike: /\+[0-9]{10}/ })).toEqual(12);
155
+ expect(toNumber("12+12", { skipLike: /\+[0-9]{10}/ })).toEqual("12+12");
156
+ expect(toNumber("12+1212121212", { skipLike: /\+[0-9]{10}/ })).toEqual("12+1212121212");
157
+ expect(toNumber("+1212121212")).toEqual(1212121212);
158
+ expect(toNumber("+1212121212", { skipLike: /\+[0-9]{10}/ })).toEqual("+1212121212");
157
159
  })
158
160
  it("should not change string if not number", () => {
159
161
  expect(toNumber("+12 12")).toEqual("+12 12");
@@ -162,7 +164,7 @@ describe("Should convert all the valid numeric strings to number", () => {
162
164
  it("should ignore sorrounded spaces ", () => {
163
165
  expect(toNumber(" +1212 ")).toEqual(1212);
164
166
  })
165
-
167
+
166
168
  it("negative numbers", () => {
167
169
  expect(toNumber("+1212")).toEqual(1212);
168
170
  expect(toNumber("+12.12")).toEqual(12.12);
@@ -0,0 +1,8 @@
1
+ import toNumber from "../strnum.js";
2
+
3
+ console.log(toNumber("1.5e3", {leadingZeros: false}))
4
+ // describe("temp", () = {
5
+
6
+ // it("scientific notation", () => {
7
+ // });
8
+ // })
package/package.json CHANGED
@@ -120,7 +120,7 @@
120
120
  "publishConfig": {
121
121
  "access": "public"
122
122
  },
123
- "version": "0.0.330",
123
+ "version": "0.0.331",
124
124
  "jest": {
125
125
  "coverageProvider": "v8",
126
126
  "testMatch": [
@@ -1,129 +0,0 @@
1
- const hexRegex = /^[-+]?0x[a-fA-F0-9]+$/;
2
- const numRegex = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/;
3
- // const octRegex = /^0x[a-z0-9]+/;
4
- // const binRegex = /0x[a-z0-9]+/;
5
-
6
-
7
- const consider = {
8
- hex : true,
9
- // oct: false,
10
- leadingZeros: true,
11
- decimalPoint: "\.",
12
- eNotation: true,
13
- //skipLike: /regex/
14
- };
15
-
16
- export default function toNumber(str, options = {}){
17
- options = Object.assign({}, consider, options );
18
- if(!str || typeof str !== "string" ) return str;
19
-
20
- let trimmedStr = str.trim();
21
-
22
- if(options.skipLike !== undefined && options.skipLike.test(trimmedStr)) return str;
23
- else if(str==="0") return 0;
24
- else if (options.hex && hexRegex.test(trimmedStr)) {
25
- return parse_int(trimmedStr, 16);
26
- // }else if (options.oct && octRegex.test(str)) {
27
- // return Number.parseInt(val, 8);
28
- }else if (trimmedStr.includes('e') || trimmedStr.includes('E')) { //eNotation
29
- return resolveEnotation(str,trimmedStr,options);
30
- // }else if (options.parseBin && binRegex.test(str)) {
31
- // return Number.parseInt(val, 2);
32
- }else{
33
- //separate negative sign, leading zeros, and rest number
34
- const match = numRegex.exec(trimmedStr);
35
- // +00.123 => [ , '+', '00', '.123', ..
36
- if(match){
37
- const sign = match[1] || "";
38
- const leadingZeros = match[2];
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
-
44
- //trim ending zeros for floating number
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
- }
51
- else{//no leading zeros or leading zeros are allowed
52
- const num = Number(trimmedStr);
53
- const parsedStr = String(num);
54
-
55
- if( num === 0) return num;
56
- if(parsedStr.search(/[eE]/) !== -1){ //given number is long and parsed to eNotation
57
- if(options.eNotation) return num;
58
- else return str;
59
- }else if(trimmedStr.indexOf(".") !== -1){ //floating number
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;
63
- else return str;
64
- }
65
-
66
- let n = leadingZeros? numTrimmedByZeros : trimmedStr;
67
- if(leadingZeros){
68
- // -009 => -9
69
- return (n === parsedStr) || (sign+n === parsedStr) ? num : str
70
- }else {
71
- // +9
72
- return (n === parsedStr) || (n === sign+parsedStr) ? num : str
73
- }
74
- }
75
- }else{ //non-numeric string
76
- return str;
77
- }
78
- }
79
- }
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
-
107
- /**
108
- *
109
- * @param {string} numStr without leading zeros
110
- * @returns
111
- */
112
- function trimZeros(numStr){
113
- if(numStr && numStr.indexOf(".") !== -1){//float
114
- numStr = numStr.replace(/0+$/, ""); //remove ending zeros
115
- if(numStr === ".") numStr = "0";
116
- else if(numStr[0] === ".") numStr = "0"+numStr;
117
- else if(numStr[numStr.length-1] === ".") numStr = numStr.substring(0,numStr.length-1);
118
- return numStr;
119
- }
120
- return numStr;
121
- }
122
-
123
- function parse_int(numStr, base){
124
- //polyfill
125
- if(parseInt) return parseInt(numStr, base);
126
- else if(Number.parseInt) return Number.parseInt(numStr, base);
127
- else if(window && window.parseInt) return window.parseInt(numStr, base);
128
- else throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")
129
- }
@@ -1,9 +0,0 @@
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
- });
@@ -1 +0,0 @@
1
- (()=>{"use strict";var t={d:(e,i)=>{for(var s in i)t.o(i,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:i[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function i(t,e){let i="";return e.format&&e.indentBy.length>0&&(i="\n"),s(t,e,"",i)}function s(t,e,i,p){let u="",h=!1;if(!Array.isArray(t)){if(null!=t){let i=t.toString();return i=a(i,e),i}return""}for(let l=0;l<t.length;l++){const d=t[l],c=n(d);if(void 0===c)continue;let f="";if(f=0===i.length?c:`${i}.${c}`,c===e.textNodeName){let t=d[c];r(f,e)||(t=e.tagValueProcessor(c,t),t=a(t,e)),h&&(u+=p),u+=t,h=!1;continue}if(c===e.cdataPropName){h&&(u+=p),u+=`<![CDATA[${d[c][0][e.textNodeName]}]]>`,h=!1;continue}if(c===e.commentPropName){u+=p+`\x3c!--${d[c][0][e.textNodeName]}--\x3e`,h=!0;continue}if("?"===c[0]){const t=o(d[":@"],e),i="?xml"===c?"":p;let s=d[c][0][e.textNodeName];s=0!==s.length?" "+s:"",u+=i+`<${c}${s}${t}?>`,h=!0;continue}let g=p;""!==g&&(g+=e.indentBy);const N=p+`<${c}${o(d[":@"],e)}`,b=s(d[c],e,f,g);-1!==e.unpairedTags.indexOf(c)?e.suppressUnpairedNode?u+=N+">":u+=N+"/>":b&&0!==b.length||!e.suppressEmptyNode?b&&b.endsWith(">")?u+=N+`>${b}${p}</${c}>`:(u+=N+">",b&&""!==p&&(b.includes("/>")||b.includes("</"))?u+=p+e.indentBy+b+p:u+=b,u+=`</${c}>`):u+=N+"/>",h=!0}return u}function n(t){const e=Object.keys(t);for(let i=0;i<e.length;i++){const s=e[i];if(Object.prototype.hasOwnProperty.call(t,s)&&":@"!==s)return s}}function o(t,e){let i="";if(t&&!e.ignoreAttributes)for(let s in t){if(!Object.prototype.hasOwnProperty.call(t,s))continue;let n=e.attributeValueProcessor(s,t[s]);n=a(n,e),!0===n&&e.suppressBooleanAttributes?i+=` ${s.substr(e.attributeNamePrefix.length)}`:i+=` ${s.substr(e.attributeNamePrefix.length)}="${n}"`}return i}function r(t,e){let i=(t=t.substr(0,t.length-e.textNodeName.length-1)).substr(t.lastIndexOf(".")+1);for(let s in e.stopNodes)if(e.stopNodes[s]===t||e.stopNodes[s]==="*."+i)return!0;return!1}function a(t,e){if(t&&t.length>0&&e.processEntities)for(let i=0;i<e.entities.length;i++){const s=e.entities[i];t=t.replace(s.regex,s.val)}return t}t.r(e),t.d(e,{default:()=>u});const p={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&amp;"},{regex:new RegExp(">","g"),val:"&gt;"},{regex:new RegExp("<","g"),val:"&lt;"},{regex:new RegExp("'","g"),val:"&apos;"},{regex:new RegExp('"',"g"),val:"&quot;"}],processEntities:!0,stopNodes:[],oneListGroup:!1};function u(t){var e;this.options=Object.assign({},p,t),!0===this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn="function"==typeof(e=this.options.ignoreAttributes)?e:Array.isArray(e)?t=>{for(const i of e){if("string"==typeof i&&t===i)return!0;if(i instanceof RegExp&&i.test(t))return!0}}:()=>!1,this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=d),this.processTextOrObjNode=h,this.options.format?(this.indentate=l,this.tagEndChar=">\n",this.newLine="\n"):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}function h(t,e,i,s){const n=this.j2x(t,i+1,s.concat(e));return void 0!==t[this.options.textNodeName]&&1===Object.keys(t).length?this.buildTextValNode(t[this.options.textNodeName],e,n.attrStr,i):this.buildObjectNode(n.val,e,n.attrStr,i)}function l(t){return this.options.indentBy.repeat(t)}function d(t){return!(!t.startsWith(this.options.attributeNamePrefix)||t===this.options.textNodeName)&&t.substr(this.attrPrefixLen)}u.prototype.build=function(t){return this.options.preserveOrder?i(t,this.options):(Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(t={[this.options.arrayNodeName]:t}),this.j2x(t,0,[]).val)},u.prototype.j2x=function(t,e,i){let s="",n="";const o=i.join(".");for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r))if(void 0===t[r])this.isAttribute(r)&&(n+="");else if(null===t[r])this.isAttribute(r)||r===this.options.cdataPropName?n+="":"?"===r[0]?n+=this.indentate(e)+"<"+r+"?"+this.tagEndChar:n+=this.indentate(e)+"<"+r+"/"+this.tagEndChar;else if(t[r]instanceof Date)n+=this.buildTextValNode(t[r],r,"",e);else if("object"!=typeof t[r]){const i=this.isAttribute(r);if(i&&!this.ignoreAttributesFn(i,o))s+=this.buildAttrPairStr(i,""+t[r]);else if(!i)if(r===this.options.textNodeName){let e=this.options.tagValueProcessor(r,""+t[r]);n+=this.replaceEntitiesValue(e)}else n+=this.buildTextValNode(t[r],r,"",e)}else if(Array.isArray(t[r])){const s=t[r].length;let o="",a="";for(let p=0;p<s;p++){const s=t[r][p];if(void 0===s);else if(null===s)"?"===r[0]?n+=this.indentate(e)+"<"+r+"?"+this.tagEndChar:n+=this.indentate(e)+"<"+r+"/"+this.tagEndChar;else if("object"==typeof s)if(this.options.oneListGroup){const t=this.j2x(s,e+1,i.concat(r));o+=t.val,this.options.attributesGroupName&&s.hasOwnProperty(this.options.attributesGroupName)&&(a+=t.attrStr)}else o+=this.processTextOrObjNode(s,r,e,i);else if(this.options.oneListGroup){let t=this.options.tagValueProcessor(r,s);t=this.replaceEntitiesValue(t),o+=t}else o+=this.buildTextValNode(s,r,"",e)}this.options.oneListGroup&&(o=this.buildObjectNode(o,r,a,e)),n+=o}else if(this.options.attributesGroupName&&r===this.options.attributesGroupName){const e=Object.keys(t[r]),i=e.length;for(let n=0;n<i;n++)s+=this.buildAttrPairStr(e[n],""+t[r][e[n]])}else n+=this.processTextOrObjNode(t[r],r,e,i);return{attrStr:s,val:n}},u.prototype.buildAttrPairStr=function(t,e){return e=this.options.attributeValueProcessor(t,""+e),e=this.replaceEntitiesValue(e),this.options.suppressBooleanAttributes&&"true"===e?" "+t:" "+t+'="'+e+'"'},u.prototype.buildObjectNode=function(t,e,i,s){if(""===t)return"?"===e[0]?this.indentate(s)+"<"+e+i+"?"+this.tagEndChar:this.indentate(s)+"<"+e+i+this.closeTag(e)+this.tagEndChar;{let n="</"+e+this.tagEndChar,o="";return"?"===e[0]&&(o="?",n=""),!i&&""!==i||-1!==t.indexOf("<")?!1!==this.options.commentPropName&&e===this.options.commentPropName&&0===o.length?this.indentate(s)+`\x3c!--${t}--\x3e`+this.newLine:this.indentate(s)+"<"+e+i+o+this.tagEndChar+t+this.indentate(s)+n:this.indentate(s)+"<"+e+i+o+">"+t+n}},u.prototype.closeTag=function(t){let e="";return-1!==this.options.unpairedTags.indexOf(t)?this.options.suppressUnpairedNode||(e="/"):e=this.options.suppressEmptyNode?"/":`></${t}`,e},u.prototype.buildTextValNode=function(t,e,i,s){if(!1!==this.options.cdataPropName&&e===this.options.cdataPropName)return this.indentate(s)+`<![CDATA[${t}]]>`+this.newLine;if(!1!==this.options.commentPropName&&e===this.options.commentPropName)return this.indentate(s)+`\x3c!--${t}--\x3e`+this.newLine;if("?"===e[0])return this.indentate(s)+"<"+e+i+"?"+this.tagEndChar;{let n=this.options.tagValueProcessor(e,t);return n=this.replaceEntitiesValue(n),""===n?this.indentate(s)+"<"+e+i+this.closeTag(e)+this.tagEndChar:this.indentate(s)+"<"+e+i+">"+n+"</"+e+this.tagEndChar}},u.prototype.replaceEntitiesValue=function(t){if(t&&t.length>0&&this.options.processEntities)for(let e=0;e<this.options.entities.length;e++){const i=this.options.entities[e];t=t.replace(i.regex,i.val)}return t},module.exports=e})();
@@ -1,2 +0,0 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.fxpBuilder=e():t.fxpBuilder=e()}(this,()=>(()=>{"use strict";var t={d:(e,r)=>{for(var i in r)t.o(r,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:r[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function r(t,e){var r="";return e.format&&e.indentBy.length>0&&(r="\n"),i(t,e,"",r)}function i(t,e,r,u){var p="",h=!1;if(!Array.isArray(t)){if(null!=t){var l=t.toString();return a(l,e)}return""}for(var d=0;d<t.length;d++){var f=t[d],c=n(f);if(void 0!==c){var g;if(g=0===r.length?c:r+"."+c,c!==e.textNodeName)if(c!==e.cdataPropName)if(c!==e.commentPropName)if("?"!==c[0]){var b=u;""!==b&&(b+=e.indentBy);var m=u+"<"+c+o(f[":@"],e),v=i(f[c],e,g,b);-1!==e.unpairedTags.indexOf(c)?e.suppressUnpairedNode?p+=m+">":p+=m+"/>":v&&0!==v.length||!e.suppressEmptyNode?v&&v.endsWith(">")?p+=m+">"+v+u+"</"+c+">":(p+=m+">",v&&""!==u&&(v.includes("/>")||v.includes("</"))?p+=u+e.indentBy+v+u:p+=v,p+="</"+c+">"):p+=m+"/>",h=!0}else{var N=o(f[":@"],e),y="?xml"===c?"":u,x=f[c][0][e.textNodeName];p+=y+"<"+c+(x=0!==x.length?" "+x:"")+N+"?>",h=!0}else p+=u+"\x3c!--"+f[c][0][e.textNodeName]+"--\x3e",h=!0;else h&&(p+=u),p+="<![CDATA["+f[c][0][e.textNodeName]+"]]>",h=!1;else{var P=f[c];s(g,e)||(P=a(P=e.tagValueProcessor(c,P),e)),h&&(p+=u),p+=P,h=!1}}}return p}function n(t){for(var e=Object.keys(t),r=0;r<e.length;r++){var i=e[r];if(Object.prototype.hasOwnProperty.call(t,i)&&":@"!==i)return i}}function o(t,e){var r="";if(t&&!e.ignoreAttributes)for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var n=e.attributeValueProcessor(i,t[i]);!0===(n=a(n,e))&&e.suppressBooleanAttributes?r+=" "+i.substr(e.attributeNamePrefix.length):r+=" "+i.substr(e.attributeNamePrefix.length)+'="'+n+'"'}return r}function s(t,e){var r=(t=t.substr(0,t.length-e.textNodeName.length-1)).substr(t.lastIndexOf(".")+1);for(var i in e.stopNodes)if(e.stopNodes[i]===t||e.stopNodes[i]==="*."+r)return!0;return!1}function a(t,e){if(t&&t.length>0&&e.processEntities)for(var r=0;r<e.entities.length;r++){var i=e.entities[r];t=t.replace(i.regex,i.val)}return t}function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=Array(e);r<e;r++)i[r]=t[r];return i}t.r(e),t.d(e,{default:()=>h});var p={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&amp;"},{regex:new RegExp(">","g"),val:"&gt;"},{regex:new RegExp("<","g"),val:"&lt;"},{regex:new RegExp("'","g"),val:"&apos;"},{regex:new RegExp('"',"g"),val:"&quot;"}],processEntities:!0,stopNodes:[],oneListGroup:!1};function h(t){var e;this.options=Object.assign({},p,t),!0===this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn="function"==typeof(e=this.options.ignoreAttributes)?e:Array.isArray(e)?function(t){for(var r,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return u(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var i=0;return function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(e);!(r=i()).done;){var n=r.value;if("string"==typeof n&&t===n)return!0;if(n instanceof RegExp&&n.test(t))return!0}}:function(){return!1},this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=f),this.processTextOrObjNode=l,this.options.format?(this.indentate=d,this.tagEndChar=">\n",this.newLine="\n"):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}function l(t,e,r,i){var n=this.j2x(t,r+1,i.concat(e));return void 0!==t[this.options.textNodeName]&&1===Object.keys(t).length?this.buildTextValNode(t[this.options.textNodeName],e,n.attrStr,r):this.buildObjectNode(n.val,e,n.attrStr,r)}function d(t){return this.options.indentBy.repeat(t)}function f(t){return!(!t.startsWith(this.options.attributeNamePrefix)||t===this.options.textNodeName)&&t.substr(this.attrPrefixLen)}return h.prototype.build=function(t){return this.options.preserveOrder?r(t,this.options):(Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&((e={})[this.options.arrayNodeName]=t,t=e),this.j2x(t,0,[]).val);var e},h.prototype.j2x=function(t,e,r){var i="",n="",o=r.join(".");for(var s in t)if(Object.prototype.hasOwnProperty.call(t,s))if(void 0===t[s])this.isAttribute(s)&&(n+="");else if(null===t[s])this.isAttribute(s)||s===this.options.cdataPropName?n+="":"?"===s[0]?n+=this.indentate(e)+"<"+s+"?"+this.tagEndChar:n+=this.indentate(e)+"<"+s+"/"+this.tagEndChar;else if(t[s]instanceof Date)n+=this.buildTextValNode(t[s],s,"",e);else if("object"!=typeof t[s]){var a=this.isAttribute(s);if(a&&!this.ignoreAttributesFn(a,o))i+=this.buildAttrPairStr(a,""+t[s]);else if(!a)if(s===this.options.textNodeName){var u=this.options.tagValueProcessor(s,""+t[s]);n+=this.replaceEntitiesValue(u)}else n+=this.buildTextValNode(t[s],s,"",e)}else if(Array.isArray(t[s])){for(var p=t[s].length,h="",l="",d=0;d<p;d++){var f=t[s][d];if(void 0===f);else if(null===f)"?"===s[0]?n+=this.indentate(e)+"<"+s+"?"+this.tagEndChar:n+=this.indentate(e)+"<"+s+"/"+this.tagEndChar;else if("object"==typeof f)if(this.options.oneListGroup){var c=this.j2x(f,e+1,r.concat(s));h+=c.val,this.options.attributesGroupName&&f.hasOwnProperty(this.options.attributesGroupName)&&(l+=c.attrStr)}else h+=this.processTextOrObjNode(f,s,e,r);else if(this.options.oneListGroup){var g=this.options.tagValueProcessor(s,f);h+=g=this.replaceEntitiesValue(g)}else h+=this.buildTextValNode(f,s,"",e)}this.options.oneListGroup&&(h=this.buildObjectNode(h,s,l,e)),n+=h}else if(this.options.attributesGroupName&&s===this.options.attributesGroupName)for(var b=Object.keys(t[s]),m=b.length,v=0;v<m;v++)i+=this.buildAttrPairStr(b[v],""+t[s][b[v]]);else n+=this.processTextOrObjNode(t[s],s,e,r);return{attrStr:i,val:n}},h.prototype.buildAttrPairStr=function(t,e){return e=this.options.attributeValueProcessor(t,""+e),e=this.replaceEntitiesValue(e),this.options.suppressBooleanAttributes&&"true"===e?" "+t:" "+t+'="'+e+'"'},h.prototype.buildObjectNode=function(t,e,r,i){if(""===t)return"?"===e[0]?this.indentate(i)+"<"+e+r+"?"+this.tagEndChar:this.indentate(i)+"<"+e+r+this.closeTag(e)+this.tagEndChar;var n="</"+e+this.tagEndChar,o="";return"?"===e[0]&&(o="?",n=""),!r&&""!==r||-1!==t.indexOf("<")?!1!==this.options.commentPropName&&e===this.options.commentPropName&&0===o.length?this.indentate(i)+"\x3c!--"+t+"--\x3e"+this.newLine:this.indentate(i)+"<"+e+r+o+this.tagEndChar+t+this.indentate(i)+n:this.indentate(i)+"<"+e+r+o+">"+t+n},h.prototype.closeTag=function(t){var e="";return-1!==this.options.unpairedTags.indexOf(t)?this.options.suppressUnpairedNode||(e="/"):e=this.options.suppressEmptyNode?"/":"></"+t,e},h.prototype.buildTextValNode=function(t,e,r,i){if(!1!==this.options.cdataPropName&&e===this.options.cdataPropName)return this.indentate(i)+"<![CDATA["+t+"]]>"+this.newLine;if(!1!==this.options.commentPropName&&e===this.options.commentPropName)return this.indentate(i)+"\x3c!--"+t+"--\x3e"+this.newLine;if("?"===e[0])return this.indentate(i)+"<"+e+r+"?"+this.tagEndChar;var n=this.options.tagValueProcessor(e,t);return""===(n=this.replaceEntitiesValue(n))?this.indentate(i)+"<"+e+r+this.closeTag(e)+this.tagEndChar:this.indentate(i)+"<"+e+r+">"+n+"</"+e+this.tagEndChar},h.prototype.replaceEntitiesValue=function(t){if(t&&t.length>0&&this.options.processEntities)for(var e=0;e<this.options.entities.length;e++){var r=this.options.entities[e];t=t.replace(r.regex,r.val)}return t},e})());
2
- //# sourceMappingURL=builder.min.js.map