2016-05-06 11:36:36 +02:00
|
|
|
var g;
|
|
|
|
|
|
|
|
// This works in non-strict mode
|
2016-12-30 16:43:49 +01:00
|
|
|
g = (function() {
|
|
|
|
return this;
|
|
|
|
})();
|
2016-05-06 11:36:36 +02:00
|
|
|
|
|
|
|
try {
|
|
|
|
// This works if eval is allowed (see CSP)
|
2018-11-16 10:20:53 +01:00
|
|
|
g = g || new Function("return this")();
|
2018-02-25 02:00:20 +01:00
|
|
|
} catch (e) {
|
2016-05-06 11:36:36 +02:00
|
|
|
// This works if the window reference is available
|
2018-02-25 02:00:20 +01:00
|
|
|
if (typeof window === "object") g = window;
|
2016-05-06 11:36:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// g can still be undefined, but nothing to do about it...
|
|
|
|
// We return undefined, instead of nothing here, so it's
|
|
|
|
// easier to handle this case. if(!global) { ...}
|
|
|
|
|
|
|
|
module.exports = g;
|