Skip to content

Commit ed4a751

Browse files
authored
feat(utils): Use globalThis (#11351)
Now we've dropped Nove v12 we can simplify to `globalThis`: #5611 (comment)
1 parent feab8af commit ed4a751

File tree

1 file changed

+1
-39
lines changed

1 file changed

+1
-39
lines changed

packages/utils/src/worldwide.ts

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -68,46 +68,8 @@ export interface InternalGlobal {
6868
_sentryModuleMetadata?: Record<string, any>;
6969
}
7070

71-
// The code below for 'isGlobalObj' and 'GLOBAL_OBJ' was copied from core-js before modification
72-
// https://github.com/zloirock/core-js/blob/1b944df55282cdc99c90db5f49eb0b6eda2cc0a3/packages/core-js/internals/global.js
73-
// core-js has the following licence:
74-
//
75-
// Copyright (c) 2014-2022 Denis Pushkarev
76-
//
77-
// Permission is hereby granted, free of charge, to any person obtaining a copy
78-
// of this software and associated documentation files (the "Software"), to deal
79-
// in the Software without restriction, including without limitation the rights
80-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
81-
// copies of the Software, and to permit persons to whom the Software is
82-
// furnished to do so, subject to the following conditions:
83-
//
84-
// The above copyright notice and this permission notice shall be included in
85-
// all copies or substantial portions of the Software.
86-
//
87-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
88-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
89-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
90-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
91-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
92-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
93-
// THE SOFTWARE.
94-
95-
/** Returns 'obj' if it's the global object, otherwise returns undefined */
96-
function isGlobalObj(obj: { Math?: Math }): any | undefined {
97-
return obj && obj.Math == Math ? obj : undefined;
98-
}
99-
10071
/** Get's the global object for the current JavaScript runtime */
101-
export const GLOBAL_OBJ: InternalGlobal =
102-
(typeof globalThis == 'object' && isGlobalObj(globalThis)) ||
103-
// eslint-disable-next-line no-restricted-globals
104-
(typeof window == 'object' && isGlobalObj(window)) ||
105-
(typeof self == 'object' && isGlobalObj(self)) ||
106-
(typeof global == 'object' && isGlobalObj(global)) ||
107-
(function (this: any) {
108-
return this;
109-
})() ||
110-
{};
72+
export const GLOBAL_OBJ = globalThis as unknown as InternalGlobal;
11173

11274
/**
11375
* Returns a global singleton contained in the global `__SENTRY__` object.

0 commit comments

Comments
 (0)