Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

browser-or-node

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browser-or-node

Check where the code is running in the browser or node.js

  • 2.1.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is browser-or-node?

The 'browser-or-node' npm package is a utility that helps developers determine whether their code is running in a browser or Node.js environment. This can be particularly useful for writing isomorphic JavaScript that needs to behave differently depending on the runtime environment.

What are browser-or-node's main functionalities?

Detect if running in a browser

This feature allows you to check if the code is being executed in a browser environment. The 'isBrowser' boolean will be true if the code is running in a browser.

const { isBrowser } = require('browser-or-node');

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

Detect if running in Node.js

This feature allows you to check if the code is being executed in a Node.js environment. The 'isNode' boolean will be true if the code is running in Node.js.

const { isNode } = require('browser-or-node');

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

Detect if running in a web worker

This feature allows you to check if the code is being executed in a Web Worker environment. The 'isWebWorker' boolean will be true if the code is running in a Web Worker.

const { isWebWorker } = require('browser-or-node');

if (isWebWorker) {
  console.log('Running in a Web Worker');
}

Other packages similar to browser-or-node

Keywords

FAQs

Package last updated on 01 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc