UNPKG

ipfs-utils

Version:

Package to aggregate shared logic and dependencies for the IPFS ecosystem

30 lines (27 loc) 1.37 kB
'use strict' const isElectron = require('is-electron') const IS_ENV_WITH_DOM = typeof window === 'object' && typeof document === 'object' && document.nodeType === 9 // @ts-ignore const IS_ELECTRON = isElectron() const IS_BROWSER = IS_ENV_WITH_DOM && !IS_ELECTRON const IS_ELECTRON_MAIN = IS_ELECTRON && !IS_ENV_WITH_DOM const IS_ELECTRON_RENDERER = IS_ELECTRON && IS_ENV_WITH_DOM const IS_NODE = typeof require === 'function' && typeof process !== 'undefined' && typeof process.release !== 'undefined' && process.release.name === 'node' && !IS_ELECTRON // @ts-ignore - we either ignore worker scope or dom scope const IS_WEBWORKER = typeof importScripts === 'function' && typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope const IS_TEST = typeof process !== 'undefined' && typeof process.env !== 'undefined' && process.env.NODE_ENV === 'test' const IS_REACT_NATIVE = typeof navigator !== 'undefined' && navigator.product === 'ReactNative' module.exports = { isTest: IS_TEST, isElectron: IS_ELECTRON, isElectronMain: IS_ELECTRON_MAIN, isElectronRenderer: IS_ELECTRON_RENDERER, isNode: IS_NODE, /** * Detects browser main thread **NOT** web worker or service worker */ isBrowser: IS_BROWSER, isWebWorker: IS_WEBWORKER, isEnvWithDom: IS_ENV_WITH_DOM, isReactNative: IS_REACT_NATIVE }