Skip to content

Commit 4e9467e

Browse files
authored
feat(NODE-7317): use BSON.NumberUtils to determine endianness (#4808)
1 parent bf75181 commit 4e9467e

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"dependencies": {
2828
"@mongodb-js/saslprep": "^1.3.0",
29-
"bson": "^7.0.0",
29+
"bson": "^7.1.1",
3030
"mongodb-connection-string-url": "^7.0.0"
3131
},
3232
"peerDependencies": {

src/bson.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export {
2222
Long,
2323
MaxKey,
2424
MinKey,
25+
NumberUtils,
2526
ObjectId,
2627
type ObjectIdLike,
2728
serialize,

src/cmap/handshake/client_metadata.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as os from 'os';
22
import * as process from 'process';
33

4-
import { BSON, type Document, Int32 } from '../../bson';
4+
import { BSON, type Document, Int32, NumberUtils } from '../../bson';
55
import { MongoInvalidArgumentError } from '../../error';
66
import type { DriverInfo, MongoOptions } from '../../mongo_client';
77
import { fileIsAccessible } from '../../utils';
@@ -336,17 +336,18 @@ declare const Bun: { (): void; version?: string } | undefined;
336336
* with a future change to these global objects.
337337
*/
338338
function getRuntimeInfo(): string {
339+
const endianness = NumberUtils.isBigEndian ? 'BE' : 'LE';
339340
if ('Deno' in globalThis) {
340341
const version = typeof Deno?.version?.deno === 'string' ? Deno?.version?.deno : '0.0.0-unknown';
341342

342-
return `Deno v${version}, ${os.endianness()}`;
343+
return `Deno v${version}, ${endianness}`;
343344
}
344345

345346
if ('Bun' in globalThis) {
346347
const version = typeof Bun?.version === 'string' ? Bun?.version : '0.0.0-unknown';
347348

348-
return `Bun v${version}, ${os.endianness()}`;
349+
return `Bun v${version}, ${endianness}`;
349350
}
350351

351-
return `Node.js ${process.version}, ${os.endianness()}`;
352+
return `Node.js ${process.version}, ${endianness}`;
352353
}

0 commit comments

Comments
 (0)