diff --git a/lib/browser.js b/lib/browser.js index c336fe87..89c521e7 100644 --- a/lib/browser.js +++ b/lib/browser.js @@ -1,14 +1,23 @@ var _globalThis; -if (typeof globalThis === 'object') { - _globalThis = globalThis; -} else { - try { - _globalThis = require('es5-ext/global'); - } catch (error) { - } finally { - if (!_globalThis && typeof window !== 'undefined') { _globalThis = window; } - if (!_globalThis) { throw new Error('Could not determine global this'); } - } + +/** + * core-js | Denis Pushkarev (zloirock) | MIT License + * + * https://github.com/zloirock/core-js/blob/977a3a49eb9473edf470cbc5c4257bd7c8c4da33/packages/core-js/internals/global-this.js#L1 + */ +var checkGlobal = function (it) { + return it && it.Math === Math && it; +}; +var _globalThis = + checkGlobal(typeof globalThis === 'object' && globalThis) || + checkGlobal(typeof window === 'object' && window) || + checkGlobal(typeof self === 'object' && self) || + checkGlobal(typeof global === 'object' && global) || + checkGlobal(typeof this === 'object' && this) || + (function () { return this; })(); + +if (!_globalThis) { + throw new Error('Could not determine global this'); } var NativeWebSocket = _globalThis.WebSocket || _globalThis.MozWebSocket; diff --git a/package.json b/package.json index e59186fd..7365b7af 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,6 @@ "dependencies": { "bufferutil": "^4.0.1", "debug": "^2.2.0", - "es5-ext": "^0.10.63", "typedarray-to-buffer": "^3.1.5", "utf-8-validate": "^5.0.2", "yaeti": "^0.0.6" @@ -38,8 +37,8 @@ "buffer-equal": "^1.0.0", "gulp": "^4.0.2", "gulp-jshint": "^2.0.4", - "jshint-stylish": "^2.2.1", "jshint": "^2.0.0", + "jshint-stylish": "^2.2.1", "tape": "^4.9.1" }, "config": {