File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change 1
1
import { SentryEvent } from '@sentry/types' ;
2
2
import { isString } from './is' ;
3
3
4
+ /**
5
+ * Checks whether we're in the Node.js or Browser environment
6
+ *
7
+ * @returns Answer to given question
8
+ */
9
+ export function isNodeEnv ( ) : boolean {
10
+ // tslint:disable:strict-type-predicates
11
+ return Object . prototype . toString . call ( typeof process !== 'undefined' ? process : 0 ) === '[object process]' ;
12
+ }
13
+
4
14
/**
5
15
* Safely get global scope object
6
16
*
7
17
* @returns Global scope object
8
18
*/
9
19
// tslint:disable:strict-type-predicates
10
20
export function getGlobalObject ( ) : Window | NodeJS . Global | { } {
11
- return typeof window !== 'undefined'
12
- ? window
13
- : typeof global !== 'undefined'
14
- ? global
15
- : typeof self !== 'undefined'
16
- ? self
17
- : { } ;
21
+ return isNodeEnv ( ) ? global : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : { } ;
18
22
}
19
23
// tslint:enable:strict-type-predicates
20
24
You can’t perform that action at this time.
0 commit comments