-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
748798b
commit 46bd532
Showing
12 changed files
with
676 additions
and
128 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,31 @@ | ||
module.exports = function getGlobalThis() { | ||
if (typeof globalThis !== 'undefined') { | ||
// eslint-disable-next-line func-names | ||
module.exports = (function () { | ||
if (typeof globalThis === 'object') { | ||
return globalThis; | ||
} | ||
|
||
if (typeof self !== 'undefined') { | ||
return self; | ||
} | ||
let g; | ||
|
||
if (typeof window !== 'undefined') { | ||
return window; | ||
} | ||
try { | ||
// This works if eval is allowed (see CSP) | ||
// eslint-disable-next-line no-new-func | ||
g = this || new Function('return this')(); | ||
} catch (e) { | ||
// This works if the window reference is available | ||
if (typeof window === 'object') { | ||
return window; | ||
} | ||
|
||
// This works if the self reference is available | ||
if (typeof self === 'object') { | ||
return self; | ||
} | ||
|
||
if (typeof global !== 'undefined') { | ||
return global; | ||
// This works if the global reference is available | ||
if (typeof global !== 'undefined') { | ||
return global; | ||
} | ||
} | ||
|
||
throw new Error('unable to locate global object'); | ||
}; | ||
return g; | ||
})(); |
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
Oops, something went wrong.
Typo