@aws-sdk/core 3.977.5 → 3.977.7
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.
|
@@ -251,25 +251,26 @@ function jsonReviver(key, value, context) {
|
|
|
251
251
|
const numericString = context.source;
|
|
252
252
|
if (typeof value === "number") {
|
|
253
253
|
const inSafeRange = value <= Number.MAX_SAFE_INTEGER && value >= Number.MIN_SAFE_INTEGER;
|
|
254
|
-
if (
|
|
255
|
-
if (
|
|
254
|
+
if (inSafeRange) {
|
|
255
|
+
if (isRepresentable(numericString, value)) {
|
|
256
256
|
return value;
|
|
257
257
|
}
|
|
258
|
-
|
|
258
|
+
return new NumericValue(numericString, "bigDecimal");
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
if (isFractionalBigNumeric(numericString)) {
|
|
259
262
|
return new NumericValue(numericString, "bigDecimal");
|
|
260
263
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
return BigInt(Number(numericString));
|
|
264
|
-
}
|
|
265
|
-
return BigInt(numericString);
|
|
264
|
+
if (/[eE]/.test(numericString)) {
|
|
265
|
+
return expandExponentToBigInt(numericString);
|
|
266
266
|
}
|
|
267
|
+
return BigInt(numericString);
|
|
267
268
|
}
|
|
268
269
|
}
|
|
269
270
|
}
|
|
270
271
|
return value;
|
|
271
272
|
}
|
|
272
|
-
function
|
|
273
|
+
function isFractionalBigNumeric(s) {
|
|
273
274
|
const dotIndex = s.indexOf(".");
|
|
274
275
|
if (dotIndex === -1) {
|
|
275
276
|
return false;
|
|
@@ -282,6 +283,89 @@ function isFractionalNumeric(s) {
|
|
|
282
283
|
const exp = parseInt(s.slice(eIndex + 1), 10);
|
|
283
284
|
return exp < fracDigits;
|
|
284
285
|
}
|
|
286
|
+
function isRepresentable(numericString, value) {
|
|
287
|
+
if (numericString === String(value)) {
|
|
288
|
+
return true;
|
|
289
|
+
}
|
|
290
|
+
if (Object.is(value, -0)) {
|
|
291
|
+
return true;
|
|
292
|
+
}
|
|
293
|
+
if (/[eE]/.test(numericString)) {
|
|
294
|
+
return expandToDecimal(numericString) === expandToDecimal(String(value));
|
|
295
|
+
}
|
|
296
|
+
const normalized = numericString.replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "");
|
|
297
|
+
const canonical = String(value);
|
|
298
|
+
if (normalized === canonical) {
|
|
299
|
+
return true;
|
|
300
|
+
}
|
|
301
|
+
if (/[eE]/.test(canonical)) {
|
|
302
|
+
return normalized === expandToDecimal(canonical);
|
|
303
|
+
}
|
|
304
|
+
return false;
|
|
305
|
+
}
|
|
306
|
+
function expandToDecimal(s) {
|
|
307
|
+
const negative = s.startsWith("-");
|
|
308
|
+
const abs = negative ? s.slice(1) : s;
|
|
309
|
+
const eIndex = abs.search(/[eE]/);
|
|
310
|
+
let result;
|
|
311
|
+
if (eIndex === -1) {
|
|
312
|
+
result = abs;
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
const exp = parseInt(abs.slice(eIndex + 1), 10);
|
|
316
|
+
const mantissa = abs.slice(0, eIndex);
|
|
317
|
+
const dotIndex = mantissa.indexOf(".");
|
|
318
|
+
let digits;
|
|
319
|
+
let intLen;
|
|
320
|
+
if (dotIndex === -1) {
|
|
321
|
+
digits = mantissa;
|
|
322
|
+
intLen = mantissa.length;
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
digits = mantissa.slice(0, dotIndex) + mantissa.slice(dotIndex + 1);
|
|
326
|
+
intLen = dotIndex;
|
|
327
|
+
}
|
|
328
|
+
digits = digits.replace(/0+$/, "") || "0";
|
|
329
|
+
const newDotPos = intLen + exp;
|
|
330
|
+
if (digits === "0") {
|
|
331
|
+
result = "0";
|
|
332
|
+
}
|
|
333
|
+
else if (newDotPos <= 0) {
|
|
334
|
+
result = "0." + "0".repeat(-newDotPos) + digits;
|
|
335
|
+
}
|
|
336
|
+
else if (newDotPos >= digits.length) {
|
|
337
|
+
result = digits + "0".repeat(newDotPos - digits.length);
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
result = digits.slice(0, newDotPos) + "." + digits.slice(newDotPos);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
if (result.includes(".")) {
|
|
344
|
+
result = result.replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "");
|
|
345
|
+
}
|
|
346
|
+
return (negative ? "-" : "") + result;
|
|
347
|
+
}
|
|
348
|
+
function expandExponentToBigInt(s) {
|
|
349
|
+
const eIndex = s.search(/[eE]/);
|
|
350
|
+
const exp = parseInt(s.slice(eIndex + 1), 10);
|
|
351
|
+
const negative = s.startsWith("-");
|
|
352
|
+
const mantissa = s.slice(negative ? 1 : 0, eIndex);
|
|
353
|
+
const dotIndex = mantissa.indexOf(".");
|
|
354
|
+
let digits;
|
|
355
|
+
let shift;
|
|
356
|
+
if (dotIndex === -1) {
|
|
357
|
+
digits = mantissa;
|
|
358
|
+
shift = exp;
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
digits = mantissa.slice(0, dotIndex) + mantissa.slice(dotIndex + 1);
|
|
362
|
+
const fracDigits = mantissa.length - dotIndex - 1;
|
|
363
|
+
shift = exp - fracDigits;
|
|
364
|
+
}
|
|
365
|
+
digits = digits.replace(/0+$/, "") || "0";
|
|
366
|
+
const result = BigInt(digits) * 10n ** BigInt(shift + (mantissa.replace(".", "").length - digits.length));
|
|
367
|
+
return negative ? -result : result;
|
|
368
|
+
}
|
|
285
369
|
|
|
286
370
|
const REVIVER_SYMBOL = Symbol.for("@aws-sdk/reviver");
|
|
287
371
|
function needsReviver(schema) {
|
|
@@ -4,25 +4,26 @@ export function jsonReviver(key, value, context) {
|
|
|
4
4
|
const numericString = context.source;
|
|
5
5
|
if (typeof value === "number") {
|
|
6
6
|
const inSafeRange = value <= Number.MAX_SAFE_INTEGER && value >= Number.MIN_SAFE_INTEGER;
|
|
7
|
-
if (
|
|
8
|
-
if (
|
|
7
|
+
if (inSafeRange) {
|
|
8
|
+
if (isRepresentable(numericString, value)) {
|
|
9
9
|
return value;
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
return new NumericValue(numericString, "bigDecimal");
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
if (isFractionalBigNumeric(numericString)) {
|
|
12
15
|
return new NumericValue(numericString, "bigDecimal");
|
|
13
16
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return BigInt(Number(numericString));
|
|
17
|
-
}
|
|
18
|
-
return BigInt(numericString);
|
|
17
|
+
if (/[eE]/.test(numericString)) {
|
|
18
|
+
return expandExponentToBigInt(numericString);
|
|
19
19
|
}
|
|
20
|
+
return BigInt(numericString);
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
return value;
|
|
24
25
|
}
|
|
25
|
-
function
|
|
26
|
+
function isFractionalBigNumeric(s) {
|
|
26
27
|
const dotIndex = s.indexOf(".");
|
|
27
28
|
if (dotIndex === -1) {
|
|
28
29
|
return false;
|
|
@@ -35,3 +36,86 @@ function isFractionalNumeric(s) {
|
|
|
35
36
|
const exp = parseInt(s.slice(eIndex + 1), 10);
|
|
36
37
|
return exp < fracDigits;
|
|
37
38
|
}
|
|
39
|
+
function isRepresentable(numericString, value) {
|
|
40
|
+
if (numericString === String(value)) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
if (Object.is(value, -0)) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
if (/[eE]/.test(numericString)) {
|
|
47
|
+
return expandToDecimal(numericString) === expandToDecimal(String(value));
|
|
48
|
+
}
|
|
49
|
+
const normalized = numericString.replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "");
|
|
50
|
+
const canonical = String(value);
|
|
51
|
+
if (normalized === canonical) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
if (/[eE]/.test(canonical)) {
|
|
55
|
+
return normalized === expandToDecimal(canonical);
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
function expandToDecimal(s) {
|
|
60
|
+
const negative = s.startsWith("-");
|
|
61
|
+
const abs = negative ? s.slice(1) : s;
|
|
62
|
+
const eIndex = abs.search(/[eE]/);
|
|
63
|
+
let result;
|
|
64
|
+
if (eIndex === -1) {
|
|
65
|
+
result = abs;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
const exp = parseInt(abs.slice(eIndex + 1), 10);
|
|
69
|
+
const mantissa = abs.slice(0, eIndex);
|
|
70
|
+
const dotIndex = mantissa.indexOf(".");
|
|
71
|
+
let digits;
|
|
72
|
+
let intLen;
|
|
73
|
+
if (dotIndex === -1) {
|
|
74
|
+
digits = mantissa;
|
|
75
|
+
intLen = mantissa.length;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
digits = mantissa.slice(0, dotIndex) + mantissa.slice(dotIndex + 1);
|
|
79
|
+
intLen = dotIndex;
|
|
80
|
+
}
|
|
81
|
+
digits = digits.replace(/0+$/, "") || "0";
|
|
82
|
+
const newDotPos = intLen + exp;
|
|
83
|
+
if (digits === "0") {
|
|
84
|
+
result = "0";
|
|
85
|
+
}
|
|
86
|
+
else if (newDotPos <= 0) {
|
|
87
|
+
result = "0." + "0".repeat(-newDotPos) + digits;
|
|
88
|
+
}
|
|
89
|
+
else if (newDotPos >= digits.length) {
|
|
90
|
+
result = digits + "0".repeat(newDotPos - digits.length);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
result = digits.slice(0, newDotPos) + "." + digits.slice(newDotPos);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (result.includes(".")) {
|
|
97
|
+
result = result.replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "");
|
|
98
|
+
}
|
|
99
|
+
return (negative ? "-" : "") + result;
|
|
100
|
+
}
|
|
101
|
+
function expandExponentToBigInt(s) {
|
|
102
|
+
const eIndex = s.search(/[eE]/);
|
|
103
|
+
const exp = parseInt(s.slice(eIndex + 1), 10);
|
|
104
|
+
const negative = s.startsWith("-");
|
|
105
|
+
const mantissa = s.slice(negative ? 1 : 0, eIndex);
|
|
106
|
+
const dotIndex = mantissa.indexOf(".");
|
|
107
|
+
let digits;
|
|
108
|
+
let shift;
|
|
109
|
+
if (dotIndex === -1) {
|
|
110
|
+
digits = mantissa;
|
|
111
|
+
shift = exp;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
digits = mantissa.slice(0, dotIndex) + mantissa.slice(dotIndex + 1);
|
|
115
|
+
const fracDigits = mantissa.length - dotIndex - 1;
|
|
116
|
+
shift = exp - fracDigits;
|
|
117
|
+
}
|
|
118
|
+
digits = digits.replace(/0+$/, "") || "0";
|
|
119
|
+
const result = BigInt(digits) * 10n ** BigInt(shift + (mantissa.replace(".", "").length - digits.length));
|
|
120
|
+
return negative ? -result : result;
|
|
121
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/core",
|
|
3
|
-
"version": "3.977.
|
|
3
|
+
"version": "3.977.7",
|
|
4
4
|
"description": "Core functions & classes shared by multiple AWS SDK clients.",
|
|
5
5
|
"homepage": "https://github.com/aws/aws-sdk-js-v3/tree/main/packages-internal/core",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -124,8 +124,8 @@
|
|
|
124
124
|
"test:temp:retry": "SMITHY_NEW_RETRIES_2026=true node ./integ/retry.integ.spec && AWS_NEW_RETRIES_2026=true node ./integ/retry.integ.spec && node ./integ/retry.integ.spec"
|
|
125
125
|
},
|
|
126
126
|
"dependencies": {
|
|
127
|
-
"@aws-sdk/types": "^3.974.
|
|
128
|
-
"@aws-sdk/xml-builder": "^3.972.
|
|
127
|
+
"@aws-sdk/types": "^3.974.3",
|
|
128
|
+
"@aws-sdk/xml-builder": "^3.972.38",
|
|
129
129
|
"@aws/lambda-invoke-store": "^0.3.0",
|
|
130
130
|
"@smithy/core": "^3.31.1",
|
|
131
131
|
"@smithy/signature-v4": "^5.6.12",
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
"concurrently": "7.0.0",
|
|
139
139
|
"downlevel-dts": "0.10.1",
|
|
140
140
|
"premove": "4.0.0",
|
|
141
|
-
"typescript": "~
|
|
141
|
+
"typescript": "~6.0.3"
|
|
142
142
|
},
|
|
143
143
|
"engines": {
|
|
144
144
|
"node": ">=20.0.0"
|