Skip to content

Commit 167dbf0

Browse files
committed
Refactor: drop es5-ext
1 parent 47067c9 commit 167dbf0

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

lib/browser.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
var _globalThis;
2-
if (typeof globalThis === 'object') {
3-
_globalThis = globalThis;
4-
} else {
5-
try {
6-
_globalThis = require('es5-ext/global');
7-
} catch (error) {
8-
} finally {
9-
if (!_globalThis && typeof window !== 'undefined') { _globalThis = window; }
10-
if (!_globalThis) { throw new Error('Could not determine global this'); }
11-
}
2+
3+
/**
4+
* core-js | Denis Pushkarev (zloirock) | MIT License
5+
*
6+
* https://github.com/zloirock/core-js/blob/977a3a49eb9473edf470cbc5c4257bd7c8c4da33/packages/core-js/internals/global-this.js#L1
7+
*/
8+
var checkGlobal = function (it) {
9+
return it && it.Math === Math && it;
10+
};
11+
var _globalThis =
12+
checkGlobal(typeof globalThis === 'object' && globalThis) ||
13+
checkGlobal(typeof window === 'object' && window) ||
14+
checkGlobal(typeof self === 'object' && self) ||
15+
checkGlobal(typeof global === 'object' && global) ||
16+
checkGlobal(typeof this == 'object' && this);
17+
18+
if (!_globalThis) {
19+
throw new Error('Could not determine global this');
1220
}
1321

1422
var NativeWebSocket = _globalThis.WebSocket || _globalThis.MozWebSocket;

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"dependencies": {
3030
"bufferutil": "^4.0.1",
3131
"debug": "^2.2.0",
32-
"es5-ext": "^0.10.63",
3332
"typedarray-to-buffer": "^3.1.5",
3433
"utf-8-validate": "^5.0.2",
3534
"yaeti": "^0.0.6"
@@ -38,8 +37,8 @@
3837
"buffer-equal": "^1.0.0",
3938
"gulp": "^4.0.2",
4039
"gulp-jshint": "^2.0.4",
41-
"jshint-stylish": "^2.2.1",
4240
"jshint": "^2.0.0",
41+
"jshint-stylish": "^2.2.1",
4342
"tape": "^4.9.1"
4443
},
4544
"config": {

0 commit comments

Comments
 (0)