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.cjs
CHANGED
|
@@ -50,7 +50,7 @@ function getStylizeFunction(options) {
|
|
|
50
50
|
const BSON_MAJOR_VERSION = 6;
|
|
51
51
|
const BSON_VERSION_SYMBOL = Symbol.for('@@mdb.bson.version');
|
|
52
52
|
const BSON_INT32_MAX = 0x7fffffff;
|
|
53
|
-
const BSON_INT32_MIN = -
|
|
53
|
+
const BSON_INT32_MIN = -2147483648;
|
|
54
54
|
const BSON_INT64_MAX = Math.pow(2, 63) - 1;
|
|
55
55
|
const BSON_INT64_MIN = -Math.pow(2, 63);
|
|
56
56
|
const JS_INT_MAX = Math.pow(2, 53);
|
|
@@ -484,9 +484,15 @@ const NumberUtils = {
|
|
|
484
484
|
source[offset] * 16777216);
|
|
485
485
|
},
|
|
486
486
|
getBigInt64LE(source, offset) {
|
|
487
|
-
const
|
|
488
|
-
|
|
489
|
-
|
|
487
|
+
const hi = BigInt(source[offset + 4] +
|
|
488
|
+
source[offset + 5] * 256 +
|
|
489
|
+
source[offset + 6] * 65536 +
|
|
490
|
+
(source[offset + 7] << 24));
|
|
491
|
+
const lo = BigInt(source[offset] +
|
|
492
|
+
source[offset + 1] * 256 +
|
|
493
|
+
source[offset + 2] * 65536 +
|
|
494
|
+
source[offset + 3] * 16777216);
|
|
495
|
+
return (hi << BigInt(32)) + lo;
|
|
490
496
|
},
|
|
491
497
|
getFloat64LE: isBigEndian
|
|
492
498
|
? (source, offset) => {
|
|
@@ -1187,7 +1193,7 @@ class Long extends BSONValue {
|
|
|
1187
1193
|
return Long.MAX_UNSIGNED_VALUE;
|
|
1188
1194
|
}
|
|
1189
1195
|
else {
|
|
1190
|
-
if (value <= -
|
|
1196
|
+
if (value <= -9223372036854776e3)
|
|
1191
1197
|
return Long.MIN_VALUE;
|
|
1192
1198
|
if (value + 1 >= TWO_PWR_63_DBL)
|
|
1193
1199
|
return Long.MAX_VALUE;
|
|
@@ -1346,7 +1352,7 @@ class Long extends BSONValue {
|
|
|
1346
1352
|
throw new BSONError('division by zero');
|
|
1347
1353
|
if (wasm) {
|
|
1348
1354
|
if (!this.unsigned &&
|
|
1349
|
-
this.high === -
|
|
1355
|
+
this.high === -2147483648 &&
|
|
1350
1356
|
divisor.low === -1 &&
|
|
1351
1357
|
divisor.high === -1) {
|
|
1352
1358
|
return this;
|
|
@@ -2836,8 +2842,14 @@ function calculateElement(name, value, serializeFunctions = false, isArray = fal
|
|
|
2836
2842
|
ByteUtils.utf8ByteLength(value.toString()) +
|
|
2837
2843
|
1);
|
|
2838
2844
|
}
|
|
2845
|
+
return 0;
|
|
2846
|
+
case 'bigint':
|
|
2847
|
+
return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (8 + 1);
|
|
2848
|
+
case 'symbol':
|
|
2849
|
+
return 0;
|
|
2850
|
+
default:
|
|
2851
|
+
throw new BSONError(`Unrecognized JS type: ${typeof value}`);
|
|
2839
2852
|
}
|
|
2840
|
-
return 0;
|
|
2841
2853
|
}
|
|
2842
2854
|
|
|
2843
2855
|
function alphabetize(str) {
|
|
@@ -3095,9 +3107,8 @@ function deserializeObject(buffer, index, options, isArray = false) {
|
|
|
3095
3107
|
throw new BSONError('corrupt bson message');
|
|
3096
3108
|
const object = isArray ? [] : {};
|
|
3097
3109
|
let arrayIndex = 0;
|
|
3098
|
-
const done = false;
|
|
3099
3110
|
let isPossibleDBRef = isArray ? false : null;
|
|
3100
|
-
while (
|
|
3111
|
+
while (true) {
|
|
3101
3112
|
const elementType = buffer[index++];
|
|
3102
3113
|
if (elementType === 0)
|
|
3103
3114
|
break;
|
|
@@ -3845,8 +3856,8 @@ function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializ
|
|
|
3845
3856
|
done = !!entry.done;
|
|
3846
3857
|
if (done)
|
|
3847
3858
|
continue;
|
|
3848
|
-
const key = entry.value[0];
|
|
3849
|
-
let value = entry.value[1];
|
|
3859
|
+
const key = entry.value ? entry.value[0] : undefined;
|
|
3860
|
+
let value = entry.value ? entry.value[1] : undefined;
|
|
3850
3861
|
if (typeof value?.toBSON === 'function') {
|
|
3851
3862
|
value = value.toBSON();
|
|
3852
3863
|
}
|