forgeplus-react/node_modules/dom-lib/es/getGlobal.js

25 lines
544 B
JavaScript

// the only reliable means to get the global object is
// `Function('return this')()`
// However, this causes CSP violations in Chrome apps.
// https://github.com/tc39/proposal-global
function getGlobal() {
if (typeof globalThis !== 'undefined') {
return globalThis;
}
if (typeof self !== 'undefined') {
return self;
}
if (typeof window !== 'undefined') {
return window;
}
if (typeof global !== 'undefined') {
return global;
}
throw new Error('unable to locate global object');
}
export default getGlobal;