safeThis.js 523 Bytes
/* global globalThis */
/*
  This file is copied from `core-js`.
  https://github.com/zloirock/core-js/blob/master/packages/core-js/internals/global.js

  MIT License
  Author: Denis Pushkarev (@zloirock)
*/

const check = function (it) {
  return it && it.Math == Math && it;
};

module.exports =
  check(typeof globalThis == 'object' && globalThis) ||
  check(typeof window == 'object' && window) ||
  check(typeof self == 'object' && self) ||
  check(typeof global == 'object' && global) ||
  Function('return this')();