UNPKG

472 BJavaScriptView Raw
1var g;
2
3// This works in non-strict mode
4g = (function() {
5 return this;
6})();
7
8try {
9 // This works if eval is allowed (see CSP)
10 g = g || new Function("return this")();
11} catch (e) {
12 // This works if the window reference is available
13 if (typeof window === "object") g = window;
14}
15
16// g can still be undefined, but nothing to do about it...
17// We return undefined, instead of nothing here, so it's
18// easier to handle this case. if(!global) { ...}
19
20module.exports = g;