Created
October 2, 2019 20:22
-
-
Save BeauBouchard/c370b345b699683fe89c70d0c1ce1b33 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @return {boolean} true whether inside a node application or not. | |
**/ | |
function isNode () { | |
try { | |
return "object" === typeof process && Object.prototype.toString.call(process) === "[object process]"; | |
} catch(e) {} | |
return false; | |
} | |
/** | |
* @return {boolean} true if inside a chrome extension or not | |
**/ | |
function isExtension () { | |
try { | |
return window.chrome && chrome.runtime && chrome.runtime.id; | |
} catch(e) {} | |
return false; | |
} | |
/** | |
* @return {boolean} true if inside a react native app | |
**/ | |
function isReactNative () { | |
try { | |
return navigator && navigator.product == "ReactNative"; | |
} catch(e) {} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment