Socket
Socket
Sign inDemoInstall

node-conditions

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    node-conditions

node conditions as boolean flags


Version published
Maintainers
1
Install size
12.2 kB
Created

Readme

Source

node-conditions

node conditions as boolean flags.

You can read more about node conditions in the node documentation about conditional exports, resolving user conditions and community conditions.

usage

esm

// via named export
import { BROWSER } from 'node-conditions';

if (BROWSER) {
	alert('hello browser');
} else {
	console.log('hello console');
}

// via star-alias
import * as conditions from 'node-conditions';
console.log(Object.keys(conditions)); // prints all available conditions

// via default export on subpath, can be any name
import isBrowser from 'node-conditions/browser';

cjs

// via mapped require
const { BROWSER } = require('node-conditions');

if (BROWSER) {
	alert('hello browser');
} else {
	console.log('hello console');
}

// via require
const conditions = require('node-conditions');
console.log(Object.keys(conditions)); // prints all available conditions

// via require of subpath, can be any name
const isBrowser = require('node-conditions/browser');

available conditions

  • BROWSER
  • NODE
  • NODE_ADDONS
  • DENO
  • BUN
  • WORKER
  • EDGE_ROUTINE
  • WORKERD
  • LAGON
  • REACT_NATIVE
  • NETLIFY
  • ELECTRON
  • EDGE_LIGHT
  • DEVELOPMENT
  • TEST
  • PRODUCTION
  • ASTRO
  • IMBA
  • SOLID
  • SVELTE
  • REACT_SERVER
  • TYPES
  • MODULE
  • IMPORT
  • REQUIRE

Keywords

FAQs

Last updated on 24 Feb 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc