UNPKG

1.19 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.getGlobal = void 0;
4/**
5 * This function returns the global object across Node and browsers.
6 *
7 * Note: `globalThis` is the standardized approach however it has been added to
8 * Node.js in version 12. We need to include this snippet until Node 12 EOL.
9 */
10function getGlobal() {
11 if (typeof globalThis !== 'undefined') {
12 return globalThis;
13 }
14 if (typeof global !== 'undefined') {
15 return global;
16 }
17 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
18 // @ts-ignore: Cannot find name 'window'.
19 if (typeof window !== 'undefined') {
20 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
21 // @ts-ignore: Cannot find name 'window'.
22 return window;
23 }
24 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
25 // @ts-ignore: Cannot find name 'self'.
26 if (typeof self !== 'undefined') {
27 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
28 // @ts-ignore: Cannot find name 'self'.
29 return self;
30 }
31}
32exports.getGlobal = getGlobal;
33//# sourceMappingURL=get-global.util.js.map
\No newline at end of file