Comparing version 6.7.0 to 6.8.0
@@ -763,9 +763,3 @@ /** | ||
* Constructs a 64 bit two's-complement integer, given its low and high 32 bit values as *signed* integers. | ||
* See the from* functions below for more convenient ways of constructing Longs. | ||
* | ||
* Acceptable signatures are: | ||
* - Long(low, high, unsigned?) | ||
* - Long(bigint, unsigned?) | ||
* - Long(string, unsigned?) | ||
* | ||
* @param low - The low (signed) 32 bits of the long | ||
@@ -775,3 +769,17 @@ * @param high - The high (signed) 32 bits of the long | ||
*/ | ||
constructor(low?: number | bigint | string, high?: number | boolean, unsigned?: boolean); | ||
constructor(low: number, high?: number, unsigned?: boolean); | ||
/** | ||
* Constructs a 64 bit two's-complement integer, given a bigint representation. | ||
* | ||
* @param value - BigInt representation of the long value | ||
* @param unsigned - Whether unsigned or not, defaults to signed | ||
*/ | ||
constructor(value: bigint, unsigned?: boolean); | ||
/** | ||
* Constructs a 64 bit two's-complement integer, given a string representation. | ||
* | ||
* @param value - String representation of the long value | ||
* @param unsigned - Whether unsigned or not, defaults to signed | ||
*/ | ||
constructor(value: string, unsigned?: boolean); | ||
static TWO_PWR_24: Long; | ||
@@ -778,0 +786,0 @@ /** Maximum unsigned value. */ |
@@ -17,3 +17,3 @@ { | ||
"types": "bson.d.ts", | ||
"version": "6.7.0", | ||
"version": "6.8.0", | ||
"author": { | ||
@@ -32,3 +32,2 @@ "name": "The MongoDB NodeJS Team", | ||
"@microsoft/api-extractor": "^7.43.1", | ||
"@octokit/core": "^6.1.2", | ||
"@rollup/plugin-node-resolve": "^15.2.3", | ||
@@ -35,0 +34,0 @@ "@rollup/plugin-typescript": "^11.1.6", |
@@ -14,2 +14,29 @@ # BSON parser | ||
### Release Integrity | ||
Releases are created automatically and signed using the [Node team's GPG key](https://pgp.mongodb.com/node-driver.asc). This applies to the git tag as well as all release packages provided as part of a GitHub release. To verify the provided packages, download the key and import it using gpg: | ||
```shell | ||
gpg --import node-driver.asc | ||
``` | ||
The GitHub release contains a detached signature file for the NPM package (named | ||
`bson-X.Y.Z.tgz.sig`). | ||
The following command returns the link npm package. | ||
```shell | ||
npm view bson@vX.Y.Z dist.tarball | ||
``` | ||
Using the result of the above command, a `curl` command can return the official npm package for the release. | ||
To verify the integrity of the downloaded package, run the following command: | ||
```shell | ||
gpg --verify bson-X.Y.Z.tgz.sig bson-X.Y.Z.tgz | ||
``` | ||
>[!Note] | ||
No verification is done when using npm to install the package. The contents of the Github tarball and npm's tarball are identical. | ||
## Bugs / Feature Requests | ||
@@ -16,0 +43,0 @@ |
@@ -122,3 +122,3 @@ import { BSONValue } from './bson_value'; | ||
*/ | ||
high!: number; | ||
high: number; | ||
@@ -128,3 +128,3 @@ /** | ||
*/ | ||
low!: number; | ||
low: number; | ||
@@ -134,13 +134,7 @@ /** | ||
*/ | ||
unsigned!: boolean; | ||
unsigned: boolean; | ||
/** | ||
* Constructs a 64 bit two's-complement integer, given its low and high 32 bit values as *signed* integers. | ||
* See the from* functions below for more convenient ways of constructing Longs. | ||
* | ||
* Acceptable signatures are: | ||
* - Long(low, high, unsigned?) | ||
* - Long(bigint, unsigned?) | ||
* - Long(string, unsigned?) | ||
* | ||
* @param low - The low (signed) 32 bits of the long | ||
@@ -150,13 +144,34 @@ * @param high - The high (signed) 32 bits of the long | ||
*/ | ||
constructor(low: number | bigint | string = 0, high?: number | boolean, unsigned?: boolean) { | ||
constructor(low: number, high?: number, unsigned?: boolean); | ||
/** | ||
* Constructs a 64 bit two's-complement integer, given a bigint representation. | ||
* | ||
* @param value - BigInt representation of the long value | ||
* @param unsigned - Whether unsigned or not, defaults to signed | ||
*/ | ||
constructor(value: bigint, unsigned?: boolean); | ||
/** | ||
* Constructs a 64 bit two's-complement integer, given a string representation. | ||
* | ||
* @param value - String representation of the long value | ||
* @param unsigned - Whether unsigned or not, defaults to signed | ||
*/ | ||
constructor(value: string, unsigned?: boolean); | ||
constructor( | ||
lowOrValue: number | bigint | string = 0, | ||
highOrUnsigned?: number | boolean, | ||
unsigned?: boolean | ||
) { | ||
super(); | ||
if (typeof low === 'bigint') { | ||
Object.assign(this, Long.fromBigInt(low, !!high)); | ||
} else if (typeof low === 'string') { | ||
Object.assign(this, Long.fromString(low, !!high)); | ||
} else { | ||
this.low = low | 0; | ||
this.high = (high as number) | 0; | ||
this.unsigned = !!unsigned; | ||
} | ||
const unsignedBool = typeof highOrUnsigned === 'boolean' ? highOrUnsigned : Boolean(unsigned); | ||
const high = typeof highOrUnsigned === 'number' ? highOrUnsigned : 0; | ||
const res = | ||
typeof lowOrValue === 'string' | ||
? Long.fromString(lowOrValue, unsignedBool) | ||
: typeof lowOrValue === 'bigint' | ||
? Long.fromBigInt(lowOrValue, unsignedBool) | ||
: { low: lowOrValue | 0, high: high | 0, unsigned: unsignedBool }; | ||
this.low = res.low; | ||
this.high = res.high; | ||
this.unsigned = res.unsigned; | ||
} | ||
@@ -250,3 +265,11 @@ | ||
static fromBigInt(value: bigint, unsigned?: boolean): Long { | ||
return Long.fromString(value.toString(), unsigned); | ||
// eslint-disable-next-line no-restricted-globals | ||
const FROM_BIGINT_BIT_MASK = BigInt(0xffffffff); | ||
// eslint-disable-next-line no-restricted-globals | ||
const FROM_BIGINT_BIT_SHIFT = BigInt(32); | ||
return new Long( | ||
Number(value & FROM_BIGINT_BIT_MASK), | ||
Number((value >> FROM_BIGINT_BIT_SHIFT) & FROM_BIGINT_BIT_MASK), | ||
unsigned | ||
); | ||
} | ||
@@ -253,0 +276,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2397011
36
31025
281