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
import { BROWSER } from 'node-conditions';
if (BROWSER) {
alert('hello browser');
} else {
console.log('hello console');
}
import * as conditions from 'node-conditions';
console.log(Object.keys(conditions));
import isBrowser from 'node-conditions/browser';
cjs
const { BROWSER } = require('node-conditions');
if (BROWSER) {
alert('hello browser');
} else {
console.log('hello console');
}
const conditions = require('node-conditions');
console.log(Object.keys(conditions));
const isBrowser = require('node-conditions/browser');
available conditions
- BROWSER
- NODE
- NODE_ADDONS
- DENO
- BUN
- WORKER
- DEVELOPMENT
- TEST
- PRODUCTION
- ASTRO
- IMBA
- SOLID
- SVELTE
- TYPES
- MODULE
- IMPORT
- REQUIRE