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.rn.cjs
CHANGED
|
@@ -872,19 +872,18 @@ class Long extends BSONValue {
|
|
|
872
872
|
get __isLong__() {
|
|
873
873
|
return true;
|
|
874
874
|
}
|
|
875
|
-
constructor(
|
|
875
|
+
constructor(lowOrValue = 0, highOrUnsigned, unsigned) {
|
|
876
876
|
super();
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
}
|
|
877
|
+
const unsignedBool = typeof highOrUnsigned === 'boolean' ? highOrUnsigned : Boolean(unsigned);
|
|
878
|
+
const high = typeof highOrUnsigned === 'number' ? highOrUnsigned : 0;
|
|
879
|
+
const res = typeof lowOrValue === 'string'
|
|
880
|
+
? Long.fromString(lowOrValue, unsignedBool)
|
|
881
|
+
: typeof lowOrValue === 'bigint'
|
|
882
|
+
? Long.fromBigInt(lowOrValue, unsignedBool)
|
|
883
|
+
: { low: lowOrValue | 0, high: high | 0, unsigned: unsignedBool };
|
|
884
|
+
this.low = res.low;
|
|
885
|
+
this.high = res.high;
|
|
886
|
+
this.unsigned = res.unsigned;
|
|
888
887
|
}
|
|
889
888
|
static fromBits(lowBits, highBits, unsigned) {
|
|
890
889
|
return new Long(lowBits, highBits, unsigned);
|
|
@@ -936,7 +935,9 @@ class Long extends BSONValue {
|
|
|
936
935
|
return Long.fromBits(value % TWO_PWR_32_DBL | 0, (value / TWO_PWR_32_DBL) | 0, unsigned);
|
|
937
936
|
}
|
|
938
937
|
static fromBigInt(value, unsigned) {
|
|
939
|
-
|
|
938
|
+
const FROM_BIGINT_BIT_MASK = BigInt(0xffffffff);
|
|
939
|
+
const FROM_BIGINT_BIT_SHIFT = BigInt(32);
|
|
940
|
+
return new Long(Number(value & FROM_BIGINT_BIT_MASK), Number((value >> FROM_BIGINT_BIT_SHIFT) & FROM_BIGINT_BIT_MASK), unsigned);
|
|
940
941
|
}
|
|
941
942
|
static _fromString(str, unsigned, radix) {
|
|
942
943
|
if (str.length === 0)
|