runtector
v0.0.1
Published
JavaScript runtime detector
Maintainers
Readme
runtector
JavaScript runtime detector
Installation
npm install runtectorUsage
import {
getCurRuntime,
isBrowser,
isBun,
isDeno,
isHappyDOM,
isJSDOM,
isNode,
isWebWorker,
} from 'runtector'API
isBrowser()trueif the current environment is a browser. If the environment isjsdomorhappy-domit will returnfalse.isNode()trueif the current environment is Node.js.isWebWorker()trueif the current environment is a Web Worker.isDeno()trueif the current environment is Deno.isBun()trueif the current environment is Bun.isJSDOM()trueif the current environment is JSDOM.isHappyDOM()trueif the current environment is HappyDOM.getCurRuntime()Example:
// Node.js environment import { getCurRuntime } from 'runtector' console.log(getCurRuntime()) /** * ===> * { * isBrowser: false, * isNode: true, * isWebWorker: false, * isDeno: false, * isBun: false, * isJSDOM: false, * isHappyDOM: false * } */
License
MIT License © MOOZON WEI
