bson 6.7.1 → 6.8.1
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.cjs
CHANGED
|
@@ -855,19 +855,18 @@ class Long extends BSONValue {
|
|
|
855
855
|
get __isLong__() {
|
|
856
856
|
return true;
|
|
857
857
|
}
|
|
858
|
-
constructor(
|
|
858
|
+
constructor(lowOrValue = 0, highOrUnsigned, unsigned) {
|
|
859
859
|
super();
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
}
|
|
860
|
+
const unsignedBool = typeof highOrUnsigned === 'boolean' ? highOrUnsigned : Boolean(unsigned);
|
|
861
|
+
const high = typeof highOrUnsigned === 'number' ? highOrUnsigned : 0;
|
|
862
|
+
const res = typeof lowOrValue === 'string'
|
|
863
|
+
? Long.fromString(lowOrValue, unsignedBool)
|
|
864
|
+
: typeof lowOrValue === 'bigint'
|
|
865
|
+
? Long.fromBigInt(lowOrValue, unsignedBool)
|
|
866
|
+
: { low: lowOrValue | 0, high: high | 0, unsigned: unsignedBool };
|
|
867
|
+
this.low = res.low;
|
|
868
|
+
this.high = res.high;
|
|
869
|
+
this.unsigned = res.unsigned;
|
|
871
870
|
}
|
|
872
871
|
static fromBits(lowBits, highBits, unsigned) {
|
|
873
872
|
return new Long(lowBits, highBits, unsigned);
|
|
@@ -919,7 +918,9 @@ class Long extends BSONValue {
|
|
|
919
918
|
return Long.fromBits(value % TWO_PWR_32_DBL | 0, (value / TWO_PWR_32_DBL) | 0, unsigned);
|
|
920
919
|
}
|
|
921
920
|
static fromBigInt(value, unsigned) {
|
|
922
|
-
|
|
921
|
+
const FROM_BIGINT_BIT_MASK = BigInt(0xffffffff);
|
|
922
|
+
const FROM_BIGINT_BIT_SHIFT = BigInt(32);
|
|
923
|
+
return new Long(Number(value & FROM_BIGINT_BIT_MASK), Number((value >> FROM_BIGINT_BIT_SHIFT) & FROM_BIGINT_BIT_MASK), unsigned);
|
|
923
924
|
}
|
|
924
925
|
static _fromString(str, unsigned, radix) {
|
|
925
926
|
if (str.length === 0)
|