@cocopina/environment
v1.0.4
Published
A collection of runtime environment utilities and indicators
Downloads
13,494
Maintainers
Readme
environment
A collection of runtime environment utilities and indicators, providing an easy interface to decipher the current runtime environment.
Table of Contents
Installation
Install the package:
npm i @cocopina/environment
API
globalScope [Object]
The global scope, can be either "global" or "window".
Examples
// Browser
import { globalScope } from '@cocopina/environment';
console.log(globalScope === window); // true
// Node
const { globalScope } = require('@cocopina/environment');
console.log(globalScope === global); // true
node [Boolean]
Whether the current enironment is a node-like environment.
Examples
// Browser
import { node } from '@cocopina/environment';
console.log(node); // false
// Node
const { node } = require('@cocopina/environment');
console.log(node); // true
browser [Boolean]
Whether the current enironment is a browser environment.
Examples
// Browser
import { browser } from '@cocopina/environment';
console.log(browser); // true
// Node
const { browser } = require('@cocopina/environment');
console.log(browser); // false