Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

actress-env

actress5MIT0.1.2

Test if the environment is a browser, bundler, node, or react native

isbrowser, is-browser, universal, isomorphic, environment, client, server, react-native, actress

readme

actress-env

NPM Version NPM Downloads

Check features of the current environment. You can have a window in your Node, Webpack, React Native, or Cordova environment, but it doesn't necessarily mean it's a browser. This is where this package comes in. Distinguish target and features of your current environment!

Installation

npm i -S actress-env

Usage

Include the library:

    // CommonJS
    const actressEnv = require('actress-env')

    // or AMD
    define(['actress-env'], (actressEnv) => {
        // ...
    })

    // or accessible via script tag on `window.__actressEnv__`
    // <script src="actress-env.js"></script>

Examples

If you're in a webpack or browserify like environment, you may receive an object similar to this:

console.log(require('actress-env'))
{
  "target": "browser",
  "isBrowser": true,
  "isBundler": true,
  "isReactNative": false,
  "isNode": false,
  "hasRequire": true,
  "hasWindow": true,
  "hasProcess": true,
  "hasGlobal": true
}