fix: handle globalThis undefined in legacy browsers

This commit is contained in:
Filip Skokan 2020-11-24 14:53:08 +01:00
parent ff98da6fe1
commit b83c59bb43

View file

@ -1,9 +1,10 @@
/* eslint-disable no-restricted-globals */
function getGlobal() {
if (typeof globalThis !== 'undefined') return globalThis
if (typeof self !== 'undefined') return self
if (typeof window !== 'undefined') return window
throw new Error('unable to locate global object')
}
export default globalThis || getGlobal()
export default getGlobal()