google_forms/node_modules/environment
RameshT 4cdf3fdf5d initial 2024-07-29 14:47:16 +05:30
..
index.d.ts initial 2024-07-29 14:47:16 +05:30
index.js initial 2024-07-29 14:47:16 +05:30
license initial 2024-07-29 14:47:16 +05:30
package.json initial 2024-07-29 14:47:16 +05:30
readme.md initial 2024-07-29 14:47:16 +05:30

readme.md

environment

Check which JavaScript environment your code is running in at runtime

Install

npm install environment

Usage

import {isBrowser, isNode} from 'environment';

if (isBrowser) {
	console.log('Running in a browser!');
}

if (isNode) {
	console.log('Running in Node.js!');
}

[!NOTE] Runtime checks should be used sparingly. Prefer conditional package exports and imports whenever possible.

API

isBrowser

Check if the code is running in a web browser environment.

isNode

Check if the code is running in a Node.js environment.

isBun

Check if the code is running in a Bun environment.

isDeno

Check if the code is running in a Deno environment.

isElectron

Check if the code is running in an Electron environment.

isJsDom

Check if the code is running in a jsdom environment.

isWebWorker

Check if the code is running in a Web Worker environment, which could be either a dedicated worker, shared worker, or service worker.

isDedicatedWorker

Check if the code is running in a Dedicated Worker environment.

isSharedWorker

Check if the code is running in a Shared Worker environment.

isServiceWorker

Check if the code is running in a Service Worker environment.

isMacOs

Check if the code is running on macOS.

isWindows

Check if the code is running on Windows.

isLinux

Check if the code is running on Linux.

isIos

Check if the code is running on iOS.

isAndroid

Check if the code is running on Android.

  • is-in-ci - Check if the process is running in a CI environment
  • is64bit - Check if the operating system CPU architecture is 64-bit or 32-bit
  • is - Type check values