2020-03-12 18:53:34 +01:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
import { Logger } from "@ethersproject/logger";
|
|
|
|
import { version } from "./_version";
|
|
|
|
|
2020-04-18 02:46:52 -04:00
|
|
|
let WS: any = null;
|
2020-03-12 18:53:34 +01:00
|
|
|
|
2020-04-18 02:46:52 -04:00
|
|
|
try {
|
|
|
|
WS = (WebSocket as any);
|
|
|
|
if (WS == null) { throw new Error("inject please"); }
|
|
|
|
} catch (error) {
|
2020-03-12 18:53:34 +01:00
|
|
|
const logger = new Logger(version);
|
|
|
|
WS = function() {
|
|
|
|
logger.throwError("WebSockets not supported in this environment", Logger.errors.UNSUPPORTED_OPERATION, {
|
|
|
|
operation: "new WebSocket()"
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = WS;
|