Created
July 6, 2020 04:02
-
-
Save DavidWells/54d76ec16f1c4b3a2a94fd8777ccc855 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
function getGlobalThis() { | |
if (typeof globalThis !== 'undefined') return globalThis | |
if (typeof global !== 'undefined') return global | |
if (typeof self !== 'undefined') return self /* eslint-disable-line no-restricted-globals */ | |
if (typeof window !== 'undefined') return window | |
if (typeof this !== 'undefined') return this | |
return {} // should never happen | |
} |
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
const globalContext = | |
(typeof self === 'object' && self.self === self && self) || | |
(typeof global === 'object' && global.global === global && global) || | |
this |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment