From 1476a9898b9338765648d4a4f90287aea021d275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20Brian=C3=A7on?= Date: Fri, 12 Aug 2022 12:58:12 +0200 Subject: [PATCH 1/2] Handle Buffer message data --- src/helpers/normalize-send.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/helpers/normalize-send.js b/src/helpers/normalize-send.js index ebb209bb..4fa6f25b 100644 --- a/src/helpers/normalize-send.js +++ b/src/helpers/normalize-send.js @@ -1,5 +1,7 @@ export default function normalizeSendData(data) { - if (Object.prototype.toString.call(data) !== '[object Blob]' && !(data instanceof ArrayBuffer)) { + if (data instanceof Buffer) { + data = data.buffer; + } else if (Object.prototype.toString.call(data) !== '[object Blob]' && !(data instanceof ArrayBuffer)) { data = String(data); } From 918ae01f20aff7c23acddd36a7e1b5299e93117f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20Brian=C3=A7on?= Date: Tue, 23 Aug 2022 09:17:37 +0200 Subject: [PATCH 2/2] Add missing url field in server type --- index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/index.d.ts b/index.d.ts index 45ad4374..909382cf 100644 --- a/index.d.ts +++ b/index.d.ts @@ -61,6 +61,7 @@ declare module 'mock-socket' { class Server extends EventTarget { constructor(url: string, options?: ServerOptions); + readonly url: string; readonly options?: ServerOptions; stop(callback?: () => void): void;