Created
March 13, 2020 11:12
-
-
Save Richienb/fc441d160fb010a65c755cba3e6e6c14 to your computer and use it in GitHub Desktop.
globalThis ponyfill.
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 === 'object') return globalThis; | |
Object.defineProperty(Object.prototype, '__magic__', { | |
get: function() { | |
return this; | |
}, | |
configurable: true | |
}); | |
const globalThis_ = __magic__; | |
delete Object.prototype.__magic__; | |
return globalThis_ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment