exenv

1.2.2last stable release 8 years ago
Complexity Score
Low
Open Issues
N/A
Dependent Projects
203
Weekly Downloadsglobal
2,051,738

License

  • BSD-3-Clause
    • Yesattribution
    • Permissivelinking
    • Permissivedistribution
    • Permissivemodification
    • Nopatent grant
    • Yesprivate use
    • Permissivesublicensing
    • Notrademark grant

Downloads

Readme

exenv

React’s ExecutionEnvironment module extracted for use in other packages & components.

Usage

npm install exenv --save
var ExecutionEnvironment = require('exenv');

// You now have...
ExecutionEnvironment.canUseDOM             // is the DOM available? i.e window document etc. 
ExecutionEnvironment.canUseWorkers         // are Web Workers available?
ExecutionEnvironment.canUseEventListeners  // are Events available? i.e addEventListener etc.
ExecutionEnvironment.canUseViewport        // is there a viewport? i.e window.screen

Differences from React’s ExecutionEnvironment

The ExecutionEnvironment lib in React 0.13 includes an isInWorker property, which is !canUseDOM. This is highly specific to React internals and probably (a) hacky and (b) not useful to other packages, so it has been left out. Please open an issue with your thoughts if you disagree or have a better idea.

Why?

A number of packages and components use React’s private ExecutionEnvironment lib to detect available features, particularly to detect server-side rendering, e.g

canUseDOM = require('react/lib/ExecutionEnvironment').canUseDOM; // BAD

It is bad practice to use React internals and this is likely to be broken / disabled in the future.

Use this package instead!

Dependencies

No runtime dependency information found for this package.

CVE IssuesActive
0
Scorecards Score
3.10
Test Coverage
No Data
Follows Semver
Yes
Github Stars
233
Dependenciestotal
0
DependenciesOutdated
0
DependenciesDeprecated
0
Threat Modelling
No Data
Repo Audits
No Data

Learn how to distribute exenv in your own private NPM registry

npm config set registry  https://npm.cloudsmith.com/owner/repo
Processing...
Done
npm install exenv
Processing...
Done

5 Releases

NPM on Cloudsmith

Getting started with NPM on Cloudsmith is fast and easy.