From 481656d16a383e905e09158cc1227d0af4237f19 Mon Sep 17 00:00:00 2001 From: Nikolaos Margaritis Date: Wed, 16 Jun 2021 15:34:57 +0300 Subject: [PATCH] Fix encoding buffer to support browsers Normally msgpack-javascript should work out of the box as the output of encode is Uint8array but due to this issue we have to initialise it again as the buffer is missing Ref https://github.com/msgpack/msgpack-javascript/issues/145 --- src/encoder.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/encoder.js b/src/encoder.js index 9747edd..c55201f 100644 --- a/src/encoder.js +++ b/src/encoder.js @@ -8,7 +8,7 @@ const buildEncoder = (options = {}) => { encode(packet) { const encoded = msgpack.encode(packet, this.options); - const buffer = Buffer.from(encoded); + const buffer = new Uint8Array(encoded); return [buffer]; }