node-conditions
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i node-conditions

Weekly Downloads

1

Version

1.2.0

License

MIT

Unpacked Size

12.5 kB

Total Files

10

Last publish

Collaborators

  • dominik_g