global.js 509 B

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