node-conditions
v1.2.0
Published
node conditions as boolean flags
Downloads
4
Readme
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