Skip to content

detectRuntime ​

Generated reference page for the detectRuntime function export.

  • Import: @kjanat/dreamcli/runtime
  • Export kind: function
  • Declared in: src/runtime/detect.ts
  • Source link: src/runtime/detect.ts:87

Signatures ​

ts
function detectRuntime(globals?: GlobalForDetect): Runtime;
ParameterTypeDescription
globalsGlobalForDetect | undefinedOverride globalThis for testing. Production callers
should omit this parameter.

Members ​

Members ​

detectRuntime ​

Detect the current JavaScript runtime.

Uses globalThis feature detection to identify the host runtime. Detection order is significant: Bun is checked before Node because Bun exposes a Node-compatible process global.

ts
(globals?: GlobalForDetect): Runtime;

Examples ​

ts
const rt = detectRuntime();
// rt === 'node' | 'bun' | 'deno' | 'unknown'

See Also ​

Released under the MIT License.