@cupglassdev/isjsruntime@0.3.0
latest
cupglassDEV/isjsruntimeDetect javascript runtime without any deps
This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers




JSR Score
100%
Published
a year ago (0.3.0)
Refer to JSR website for installing the package. Or see the instruction above the readme file
Isjsruntime
Update: Full deno support AND bun (that means the engine() function worked!). Updated readme with consistent implementation (because of the old repo). And now the script is typesafe!
Only contains 2 non-async function (which on fails, return undefined)
env(legacy=false)for detecting javascript runtime. Contains one optional parameter (boolean) for enabling the legacy detector for JSDOM, andengine()for detecting javascript engine. No parameters required
And 2 types
jsEngineListlist of accepted engine such asv8, etc.jsEnvListlist of accepted javascript runtime
Detect if running on bun (working with/without polyfill)
// import the package import * isjs from '@cupglassdev/isjsruntime' // make a function function run(){ // check using the env() function const env = isjs.env() if (env==='bun'){ console.log('you are on bun') } else { throw new Error('it looks like you are using another js enviroment') } } // run the function run()
detect if the node engine is running on v8
import * as isjs from '@cupglassdev/isjsruntime' function isusingv8() { // check using the engine() function const engine = isjs.engine() if (engine ==='v8') return true else return false; } //print it onto the console console.log(isusingv8())
Add Package
deno add jsr:@cupglassdev/isjsruntime
Import symbol
import * as isjsruntime from "@cupglassdev/isjsruntime";
Import directly with a jsr specifier
import * as isjsruntime from "jsr:@cupglassdev/isjsruntime";
Add Package
pnpm i jsr:@cupglassdev/isjsruntime
pnpm dlx jsr add @cupglassdev/isjsruntime
Import symbol
import * as isjsruntime from "@cupglassdev/isjsruntime";
Add Package
yarn add jsr:@cupglassdev/isjsruntime
yarn dlx jsr add @cupglassdev/isjsruntime
Import symbol
import * as isjsruntime from "@cupglassdev/isjsruntime";
Add Package
vlt install jsr:@cupglassdev/isjsruntime
Import symbol
import * as isjsruntime from "@cupglassdev/isjsruntime";
Add Package
npx jsr add @cupglassdev/isjsruntime
Import symbol
import * as isjsruntime from "@cupglassdev/isjsruntime";
Add Package
bunx jsr add @cupglassdev/isjsruntime
Import symbol
import * as isjsruntime from "@cupglassdev/isjsruntime";