From 7980aa29c72cd5f70a56e125cec053cae22b1fb5 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sat, 25 Feb 2023 22:38:25 -0500 Subject: [PATCH] *Add websocket compatibility with readyState --- src/socket.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/socket.ts b/src/socket.ts index 5f21b0b..1bcf738 100644 --- a/src/socket.ts +++ b/src/socket.ts @@ -70,7 +70,17 @@ export default class Socket extends Duplex { return this._connecting; } - get readyState(): string { + get readyState(): string | number { + if (this._emulateWebsocket) { + if (this._connecting) { + return 0; + } else if (this.readable && this.writable) { + return 1; + } else { + return 3; + } + } + if (this._connecting) { return "opening"; } else if (this.readable && this.writable) {