All files / packages/core/src runtime.ts

100% Statements 5/5
100% Branches 0/0
100% Functions 1/1
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24      53x                         53x 53x     53x 53x    
/**
 * Detects the current JavaScript runtime and returns formatted user agent string
 */
export const detectRuntime = function detectRuntime(): string {
	let runtime: string
	let version: string
 
	/* node:coverage ignore start -- non-Node runtimes can't execute under the Node test leg */
	if (typeof (globalThis as any).Deno !== 'undefined') {
		runtime = 'deno'
		version = (globalThis as any).Deno.version.deno
	} else if (typeof (globalThis as any).Bun !== 'undefined') {
		runtime = 'bun'
		version = (globalThis as any).Bun.version
	} else {
		/* node:coverage ignore stop */
		runtime = 'node'
		version = process.versions.node
	}
 
	let platform = `${process.platform}-${process.arch}`
	return `${runtime}/${version} (${platform})`
}