is-env
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

is-env

is-env is a current detector.

Can check the js operating environment is browser or react-native or nodejs or weapp.

In addition to browser, nodejs, react-native, weapp, other output unknow.

Only ie9+ and modern browsers are supported in browsers.

install

npm install --save is-env

use

const isEnv = require('is-env');
 
isEnv('nodejs');
isEnv('react-native');
isEnv('browser');
isEnv('weapp');

When the parameter is a non string, output the current environment.

const isEnv = require('is-env');
 
switch(isEnv()) {
    case 'react-native': break;
    case 'browser': break;
    case 'nodejs': break;
    case 'weapp': break;
    case 'unknow': break;
    default: break;
}

/is-env/

    Package Sidebar

    Install

    npm i is-env

    Weekly Downloads

    3

    Version

    2.0.1

    License

    ISC

    Unpacked Size

    2.84 kB

    Total Files

    4

    Last publish

    Collaborators

    • lizhooh