Skip to content

Commit

Permalink
Use native globalThis property when available.
Browse files Browse the repository at this point in the history
Resolves #415
  • Loading branch information
theturtle32 committed Apr 14, 2021
1 parent 39bf903 commit b849ede
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/browser.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
var _globalThis;
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'); }
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'); }
}
}

var NativeWebSocket = _globalThis.WebSocket || _globalThis.MozWebSocket;
Expand Down

0 comments on commit b849ede

Please # to comment.