JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 61396
  • Score
    100M100P100Q142682F
  • License MIT

Detect which JavaScript runtime is being used.

Package Exports

  • js-runtime
  • js-runtime/package.json

Readme

js-runtime

Npm version Npm downloads Npm downloads

Detect which JavaScript runtime is being used, Bun, Deno or NodeJS.

Usage

index.ts

import { getRuntime } from "js-runtime";
console.log(getRuntime()); //node or deno or bun
$ bun index.js
$ deno run index.js
$ node index.js

API

getRuntime

Return the current runtime.

Type: function
Returns: bun | deno | node

isBun

Type: function
Returns: boolean

isDeno

Type: function
Returns: boolean

isNode

Type: function
Returns: boolean

getRuntimeVersion

Retrieve the version used in the current runtime.

Type: function
Returns: string

runtimeSwitch

Switch based on the current runtime.

Type: function
Returns: string

runtimeImport

Dynamic import based on switch data, see runtimeSwitch.

Type: function
Returns: string