nsite-ts/src/polyfill.ts

14 lines
373 B
TypeScript
Raw Normal View History

2024-10-01 12:28:34 -05:00
import { ClientOptions, WebSocket } from "ws";
import { ClientRequestArgs } from "http";
2024-09-01 13:26:37 -05:00
2024-10-01 12:28:34 -05:00
import agent from "./proxy.js";
class ProxyWebSocket extends WebSocket {
constructor(address: string | URL, options?: ClientOptions | ClientRequestArgs) {
super(address, { agent, ...options });
}
}
// @ts-expect-error
global.WebSocket = agent ? ProxyWebSocket : WebSocket;