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