From eb5d2d2c8829b481a1c018ec560da9c6b03ea9c9 Mon Sep 17 00:00:00 2001 From: xhayper Date: Fri, 1 Dec 2023 08:26:59 +0700 Subject: [PATCH] feat: apply improvment from deno --- package.json | 4 ++-- src/transport/IPC.ts | 13 ++----------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 87357cf..02ffa9b 100644 --- a/package.json +++ b/package.json @@ -29,9 +29,9 @@ }, "devDependencies": { "@types/node": "^14.*", - "@types/ws": "^8.5.9", + "@types/ws": "^8.5.10", "del-cli": "^5.1.0", - "discord-api-types": "^0.37.63" + "discord-api-types": "^0.37.65" }, "engines": { "node": ">=14.18.0" diff --git a/src/transport/IPC.ts b/src/transport/IPC.ts index ad1db18..2f0eea7 100644 --- a/src/transport/IPC.ts +++ b/src/transport/IPC.ts @@ -154,16 +154,7 @@ export class IPCTransport extends Transport { ); this.socket.on("readable", () => { - let data = this.socket?.read() as Buffer | undefined; - if (!data) return; - this.client.emit( - "debug", - `SERVER => CLIENT | ${data - .toString("hex") - .match(/.{1,2}/g) - ?.join(" ") - .toUpperCase()}` - ); + let data = Buffer.alloc(0); do { const chunk = this.socket?.read() as Buffer | undefined; @@ -227,7 +218,7 @@ export class IPCTransport extends Transport { } close(): Promise { - if (!this.socket) return new Promise((resolve) => void resolve()); + if (!this.socket) return Promise.resolve(); return new Promise((resolve) => { this.socket!.once("close", () => {