This commit is contained in:
DrSmoothl committed 2026-10-12 15:43:34 +08:00
1 parent effeb66554
commit 7c0519f75f
977 files changed
+198426 -158324

No files matched your search

+19 -25
View File
@@ -16,36 +16,30 @@ WebSocketClient.Server = WebSocketServer;
// `WebSocket` type that ships with @types/node.
export const WebSocket: typeof WebSocketClient = WebSocketClient;
export interface WebSocket extends EventEmitter {
readonly readyState: number;
readonly protocol: string;
readonly extensions: string;
send(
data: string | Buffer | Uint8Array | ArrayBuffer,
options?: SendOptions | SendCallback,
cb?: SendCallback,
): void;
ping(data?: Buffer | string | SendCallback, mask?: unknown, cb?: SendCallback): void;
pong(data?: Buffer | string | SendCallback, mask?: unknown, cb?: SendCallback): void;
close(code?: number, reason?: string): void;
terminate(): void;
on(event: 'message', listener: (data: Buffer, isBinary: boolean) => void): this;
on(event: 'open', listener: () => void): this;
on(event: 'close', listener: (code: number, reason: string) => void): this;
on(event: 'error', listener: (err: Error) => void): this;
on(event: 'ping' | 'pong', listener: (data: Buffer) => void): this;
on(event: string | symbol, listener: (...args: unknown[]) => void): this;
readonly readyState: number;
readonly protocol: string;
readonly extensions: string;
send(
data: string | Buffer | Uint8Array | ArrayBuffer,
options?: SendOptions | SendCallback,
cb?: SendCallback,
): void;
ping(data?: Buffer | string | SendCallback, mask?: unknown, cb?: SendCallback): void;
pong(data?: Buffer | string | SendCallback, mask?: unknown, cb?: SendCallback): void;
close(code?: number, reason?: string): void;
terminate(): void;
on(event: 'message', listener: (data: Buffer, isBinary: boolean) => void): this;
on(event: 'open', listener: () => void): this;
on(event: 'close', listener: (code: number, reason: string) => void): this;
on(event: 'error', listener: (err: Error) => void): this;
on(event: 'ping' | 'pong', listener: (data: Buffer) => void): this;
on(event: string | symbol, listener: (...args: unknown[]) => void): this;
}
const Server = WebSocketServer;
const _internal = { WebSocket: InternalWebSocket, native };
export {
WebSocketClient,
WebSocketServer,
Server,
InternalWebSocket,
_internal,
};
export { WebSocketClient, WebSocketServer, Server, InternalWebSocket, _internal };
export type { SendOptions, SendCallback, WebSocketRawData } from './websocket';
export type { WebSocketClientOptions } from './client';