Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: remove object case
  • Loading branch information
nbbeeken committed Apr 12, 2023
commit 0d26183df376b00ebf572555578fc80e2068eddf
4 changes: 2 additions & 2 deletions src/cmap/handshake/client_metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ declare const Deno: { version?: { deno?: string } } | undefined;
* expect it to satisfy. In order to not ship code in the driver that would break
* future versions of this runtime assume all properties are nullish.
*/
declare const Bun: { version?: string } | undefined;
declare const Bun: { (): void; version?: string } | undefined;

/**
* @internal
Expand Down Expand Up @@ -278,7 +278,7 @@ function getRuntimeInfo(): string {
if ('Bun' in globalThis) {
const version =
Bun != null &&
(typeof Bun === 'function' || typeof Bun === 'object') &&
typeof Bun === 'function' &&
'version' in Bun &&
typeof Bun.version === 'string'
? Bun.version
Expand Down
16 changes: 4 additions & 12 deletions test/unit/cmap/handshake/client_metadata.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,18 +344,10 @@ describe('client metadata module', () => {
expect(delete globalThis.Bun, 'failed to delete Bun global').to.be.true;
});

it('sets platform to Bun if typeof is object', () => {
globalThis.Bun = { version: '1.2.3' };
const metadata = makeClientMetadata({ driverInfo: {} });
expect(metadata.platform).to.equal('Bun v1.2.3, LE');
});

it('sets platform to Bun if typeof is function', () => {
function Bun() {
return null;
}
Bun.version = '1.2.3';
globalThis.Bun = Bun;
it('sets platform to Bun', () => {
globalThis.Bun = class {
static version = '1.2.3';
};
const metadata = makeClientMetadata({ driverInfo: {} });
expect(metadata.platform).to.equal('Bun v1.2.3, LE');
});
Expand Down