UNPKG

835 BJavaScriptView Raw
1import process from 'process';
2export function isNode() {
3 /**
4 * Polyfills of 'process' might set process.browser === true
5 *
6 * See:
7 * https://github.com/webpack/node-libs-browser/blob/master/mock/process.js#L8
8 * https://github.com/defunctzombie/node-process/blob/master/browser.js#L156
9 **/
10 return typeof process !== 'undefined' && !process.browser;
11}
12export function isReactNative() {
13 return (typeof window !== 'undefined' &&
14 'navigator' in window &&
15 'product' in window.navigator &&
16 window.navigator.product === 'ReactNative');
17}
18export function getNodeVersion() {
19 return process.versions && process.versions.node ? `v${process.versions.node}` : process.version;
20}
21export function getWindow() {
22 return window;
23}
24export function noop() {
25 return undefined;
26}