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