-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobalThis.js
36 lines (35 loc) · 823 Bytes
/
globalThis.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
(function() {
'use strict';
if (typeof globalThis === 'undefined') {
/* global global: true */
if (typeof window !== 'undefined') {
Object.defineProperty(Window.prototype, 'globalThis', {
enumerable: false,
writable: true,
configurable: true,
value: window,
});
} else if (typeof global !== 'undefined') {
Object.defineProperty(global, 'globalThis', {
enumerable: false,
writable: true,
configurable: true,
value: global,
});
} else if (typeof self !== 'undefined') {
Object.defineProperty(self, 'globalThis', {
enumerable: false,
writable: true,
configurable: true,
value: self,
});
} else {
Object.defineProperty(this, 'globalThis', {
enumerable: false,
writable: true,
configurable: true,
value: this,
});
}
}
})();