1.2.0 • Published 2 years ago

node-conditions v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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
1.2.0

2 years ago

1.1.0

3 years ago

1.0.0

3 years ago

1.0.0-alpha.1

3 years ago

1.0.0-alpha.0

3 years ago