ethers.js/packages/providers/src.ts/ws-browser.ts

18 lines
424 B
TypeScript
Raw Permalink Normal View History

2022-04-11 17:09:17 -04:00
declare global {
interface Window { }
const window: Window;
const self: Window;
}
function getGlobal(): any {
if (typeof self !== 'undefined') { return self; }
if (typeof window !== 'undefined') { return window; }
if (typeof global !== 'undefined') { return global; }
throw new Error('unable to locate global object');
};
const _WebSocket = getGlobal().WebSocket;
export { _WebSocket as WebSocket };