global.js 535 B

123456789101112131415
  1. module.exports = (function () {
  2. if (this) return this;
  3. // Unexpected strict mode (may happen if e.g. bundled into ESM module) be nice
  4. // Thanks @mathiasbynens -> https://mathiasbynens.be/notes/globalthis
  5. // In all ES5 engines global object inherits from Object.prototype
  6. // (if you approached one that doesn't please report)
  7. Object.defineProperty(Object.prototype, "__global__", {
  8. get: function () { return this; },
  9. configurable: true
  10. });
  11. try { return __global__; }
  12. finally { delete Object.prototype.__global__; }
  13. })();