bson 6.10.2 → 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 +15 -10
- package/lib/bson.bundle.js.map +1 -1
- package/lib/bson.cjs +15 -10
- package/lib/bson.cjs.map +1 -1
- package/lib/bson.mjs +15 -10
- package/lib/bson.mjs.map +1 -1
- package/lib/bson.rn.cjs +11 -5
- package/lib/bson.rn.cjs.map +1 -1
- package/package.json +3 -3
- 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;
|
|
@@ -3102,9 +3108,8 @@ function deserializeObject(buffer, index, options, isArray = false) {
|
|
|
3102
3108
|
throw new BSONError('corrupt bson message');
|
|
3103
3109
|
const object = isArray ? [] : {};
|
|
3104
3110
|
let arrayIndex = 0;
|
|
3105
|
-
const done = false;
|
|
3106
3111
|
let isPossibleDBRef = isArray ? false : null;
|
|
3107
|
-
while (
|
|
3112
|
+
while (true) {
|
|
3108
3113
|
const elementType = buffer[index++];
|
|
3109
3114
|
if (elementType === 0)
|
|
3110
3115
|
break;
|
|
@@ -3852,8 +3857,8 @@ function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializ
|
|
|
3852
3857
|
done = !!entry.done;
|
|
3853
3858
|
if (done)
|
|
3854
3859
|
continue;
|
|
3855
|
-
const key = entry.value[0];
|
|
3856
|
-
let value = entry.value[1];
|
|
3860
|
+
const key = entry.value ? entry.value[0] : undefined;
|
|
3861
|
+
let value = entry.value ? entry.value[1] : undefined;
|
|
3857
3862
|
if (typeof value?.toBSON === 'function') {
|
|
3858
3863
|
value = value.toBSON();
|
|
3859
3864
|
}
|