-
-
Save krackers/bc338dc4662bd1da72a5675ae796a5ed to your computer and use it in GitHub Desktop.
globalThis simple polyfil
This file contains hidden or 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 isNotUndefined = typeofResult => typeofResult !== 'undefined'; | |
if(isNotUndefined(typeof globalThis) && globalThis.globalThis === globalThis) { return; } | |
const g = (isNotUndefined(typeof window) && window) | |
|| (isNotUndefined(typeof global) && global) | |
|| (isNotUndefined(typeof self) && self) | |
|| Function('return this')(); | |
g.globalThis = g; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment