bson 6.10.1 → 6.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bson.bundle.js +22 -11
- package/lib/bson.bundle.js.map +1 -1
- package/lib/bson.cjs +22 -11
- package/lib/bson.cjs.map +1 -1
- package/lib/bson.mjs +22 -11
- package/lib/bson.mjs.map +1 -1
- package/lib/bson.rn.cjs +18 -5
- package/lib/bson.rn.cjs.map +1 -1
- package/package.json +3 -3
- package/src/parser/calculate_size.ts +8 -1
- package/src/parser/serializer.ts +2 -2
- package/src/utils/number_utils.ts +17 -8
package/lib/bson.bundle.js
CHANGED
|
@@ -51,7 +51,7 @@ function getStylizeFunction(options) {
|
|
|
51
51
|
const BSON_MAJOR_VERSION = 6;
|
|
52
52
|
const BSON_VERSION_SYMBOL = Symbol.for('@@mdb.bson.version');
|
|
53
53
|
const BSON_INT32_MAX = 0x7fffffff;
|
|
54
|
-
const BSON_INT32_MIN = -
|
|
54
|
+
const BSON_INT32_MIN = -2147483648;
|
|
55
55
|
const BSON_INT64_MAX = Math.pow(2, 63) - 1;
|
|
56
56
|
const BSON_INT64_MIN = -Math.pow(2, 63);
|
|
57
57
|
const JS_INT_MAX = Math.pow(2, 53);
|
|
@@ -485,9 +485,15 @@ const NumberUtils = {
|
|
|
485
485
|
source[offset] * 16777216);
|
|
486
486
|
},
|
|
487
487
|
getBigInt64LE(source, offset) {
|
|
488
|
-
const
|
|
489
|
-
|
|
490
|
-
|
|
488
|
+
const hi = BigInt(source[offset + 4] +
|
|
489
|
+
source[offset + 5] * 256 +
|
|
490
|
+
source[offset + 6] * 65536 +
|
|
491
|
+
(source[offset + 7] << 24));
|
|
492
|
+
const lo = BigInt(source[offset] +
|
|
493
|
+
source[offset + 1] * 256 +
|
|
494
|
+
source[offset + 2] * 65536 +
|
|
495
|
+
source[offset + 3] * 16777216);
|
|
496
|
+
return (hi << BigInt(32)) + lo;
|
|
491
497
|
},
|
|
492
498
|
getFloat64LE: isBigEndian
|
|
493
499
|
? (source, offset) => {
|
|
@@ -1188,7 +1194,7 @@ class Long extends BSONValue {
|
|
|
1188
1194
|
return Long.MAX_UNSIGNED_VALUE;
|
|
1189
1195
|
}
|
|
1190
1196
|
else {
|
|
1191
|
-
if (value <= -
|
|
1197
|
+
if (value <= -9223372036854776e3)
|
|
1192
1198
|
return Long.MIN_VALUE;
|
|
1193
1199
|
if (value + 1 >= TWO_PWR_63_DBL)
|
|
1194
1200
|
return Long.MAX_VALUE;
|
|
@@ -1347,7 +1353,7 @@ class Long extends BSONValue {
|
|
|
1347
1353
|
throw new BSONError('division by zero');
|
|
1348
1354
|
if (wasm) {
|
|
1349
1355
|
if (!this.unsigned &&
|
|
1350
|
-
this.high === -
|
|
1356
|
+
this.high === -2147483648 &&
|
|
1351
1357
|
divisor.low === -1 &&
|
|
1352
1358
|
divisor.high === -1) {
|
|
1353
1359
|
return this;
|
|
@@ -2837,8 +2843,14 @@ function calculateElement(name, value, serializeFunctions = false, isArray = fal
|
|
|
2837
2843
|
ByteUtils.utf8ByteLength(value.toString()) +
|
|
2838
2844
|
1);
|
|
2839
2845
|
}
|
|
2846
|
+
return 0;
|
|
2847
|
+
case 'bigint':
|
|
2848
|
+
return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (8 + 1);
|
|
2849
|
+
case 'symbol':
|
|
2850
|
+
return 0;
|
|
2851
|
+
default:
|
|
2852
|
+
throw new BSONError(`Unrecognized JS type: ${typeof value}`);
|
|
2840
2853
|
}
|
|
2841
|
-
return 0;
|
|
2842
2854
|
}
|
|
2843
2855
|
|
|
2844
2856
|
function alphabetize(str) {
|
|
@@ -3096,9 +3108,8 @@ function deserializeObject(buffer, index, options, isArray = false) {
|
|
|
3096
3108
|
throw new BSONError('corrupt bson message');
|
|
3097
3109
|
const object = isArray ? [] : {};
|
|
3098
3110
|
let arrayIndex = 0;
|
|
3099
|
-
const done = false;
|
|
3100
3111
|
let isPossibleDBRef = isArray ? false : null;
|
|
3101
|
-
while (
|
|
3112
|
+
while (true) {
|
|
3102
3113
|
const elementType = buffer[index++];
|
|
3103
3114
|
if (elementType === 0)
|
|
3104
3115
|
break;
|
|
@@ -3846,8 +3857,8 @@ function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializ
|
|
|
3846
3857
|
done = !!entry.done;
|
|
3847
3858
|
if (done)
|
|
3848
3859
|
continue;
|
|
3849
|
-
const key = entry.value[0];
|
|
3850
|
-
let value = entry.value[1];
|
|
3860
|
+
const key = entry.value ? entry.value[0] : undefined;
|
|
3861
|
+
let value = entry.value ? entry.value[1] : undefined;
|
|
3851
3862
|
if (typeof value?.toBSON === 'function') {
|
|
3852
3863
|
value = value.toBSON();
|
|
3853
3864
|
}
|