env
Utility class for detecting the current environment where the code is running. Can detect if the code is running in a browser, node.js, JSDOM or a web worker.
Accessors
browser
Indicates whether the code is running in a browser environment.
Syntax
get browser(): booleanReturns: true if running in a browser environment, false otherwise.
Examples
console.log(env.browser) // true or falsejsdom
Indicates whether the code is running in a JSDOM environment.
Syntax
get jsdom(): booleanReturns: true if running in a JSDOM environment, false otherwise.
Examples
console.log(env.jsdom) // true or falsenode
Indicates whether the code is running in a Node.js environment.
Syntax
get node(): booleanReturns: true if running in a Node.js environment, false otherwise.
Examples
console.log(env.node) // true or falseworker
Indicates whether the code is running in a Node.js environment.
Syntax
get worker(): booleanReturns: true if running in a Web Worker environment, false otherwise.
Examples
console.log(env.worker) // true or false