Add support for globalThis when detecting global object (#4347)

This commit is contained in:
Jack Works
2019-07-03 02:35:27 +08:00
committed by John-David Dalton
parent 4df32723c2
commit 8bc17fe659

View File

@@ -1,9 +1,12 @@
import freeGlobal from './freeGlobal.js'
/** Detect free variable `globalThis` */
const freeGlobalThis = typeof globalThis == 'object' && globalThis !== null && globalThis.Object == Object && globalThis
/** Detect free variable `self`. */
const freeSelf = typeof self == 'object' && self !== null && self.Object === Object && self
/** Used as a reference to the global object. */
const root = freeGlobal || freeSelf || Function('return this')()
const root = freeGlobalThis || freeGlobal || freeSelf || Function('return this')()
export default root