-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
34 lines (31 loc) · 802 Bytes
/
index.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
/**
* @description Simple polyfill for WeakRef
* @author Jaenster
*/
(function (global) {
if (typeof global === 'object' && global && typeof global['WeakRef'] === 'undefined') {
global.WeakRef = (function (wm) {
function WeakRef(target) {
wm.set(this, target);
}
WeakRef.prototype.deref = function () {
return wm.get(this);
};
return WeakRef;
})(new WeakMap());
}
})((function () {
switch (true) {
case typeof globalThis === 'object' && !!globalThis:
return globalThis;
case typeof self === 'object' && !!self:
return self;
case typeof window === 'object' && !!window:
return window;
case typeof global === 'object' && !!global:
return global;
case typeof Function === 'function':
return (Function('return this')());
}
return null;
})());