bson 6.7.0 → 6.8.0
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/README.md +27 -0
- package/bson.d.ts +15 -7
- package/lib/bson.bundle.js +14 -13
- package/lib/bson.bundle.js.map +1 -1
- package/lib/bson.cjs +14 -13
- package/lib/bson.cjs.map +1 -1
- package/lib/bson.mjs +14 -13
- package/lib/bson.mjs.map +1 -1
- package/lib/bson.rn.cjs +14 -13
- package/lib/bson.rn.cjs.map +1 -1
- package/package.json +1 -2
- package/src/long.ts +43 -20
package/lib/bson.mjs
CHANGED
|
@@ -853,19 +853,18 @@ class Long extends BSONValue {
|
|
|
853
853
|
get __isLong__() {
|
|
854
854
|
return true;
|
|
855
855
|
}
|
|
856
|
-
constructor(
|
|
856
|
+
constructor(lowOrValue = 0, highOrUnsigned, unsigned) {
|
|
857
857
|
super();
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
}
|
|
858
|
+
const unsignedBool = typeof highOrUnsigned === 'boolean' ? highOrUnsigned : Boolean(unsigned);
|
|
859
|
+
const high = typeof highOrUnsigned === 'number' ? highOrUnsigned : 0;
|
|
860
|
+
const res = typeof lowOrValue === 'string'
|
|
861
|
+
? Long.fromString(lowOrValue, unsignedBool)
|
|
862
|
+
: typeof lowOrValue === 'bigint'
|
|
863
|
+
? Long.fromBigInt(lowOrValue, unsignedBool)
|
|
864
|
+
: { low: lowOrValue | 0, high: high | 0, unsigned: unsignedBool };
|
|
865
|
+
this.low = res.low;
|
|
866
|
+
this.high = res.high;
|
|
867
|
+
this.unsigned = res.unsigned;
|
|
869
868
|
}
|
|
870
869
|
static fromBits(lowBits, highBits, unsigned) {
|
|
871
870
|
return new Long(lowBits, highBits, unsigned);
|
|
@@ -917,7 +916,9 @@ class Long extends BSONValue {
|
|
|
917
916
|
return Long.fromBits(value % TWO_PWR_32_DBL | 0, (value / TWO_PWR_32_DBL) | 0, unsigned);
|
|
918
917
|
}
|
|
919
918
|
static fromBigInt(value, unsigned) {
|
|
920
|
-
|
|
919
|
+
const FROM_BIGINT_BIT_MASK = BigInt(0xffffffff);
|
|
920
|
+
const FROM_BIGINT_BIT_SHIFT = BigInt(32);
|
|
921
|
+
return new Long(Number(value & FROM_BIGINT_BIT_MASK), Number((value >> FROM_BIGINT_BIT_SHIFT) & FROM_BIGINT_BIT_MASK), unsigned);
|
|
921
922
|
}
|
|
922
923
|
static _fromString(str, unsigned, radix) {
|
|
923
924
|
if (str.length === 0)
|