From 5b8876744af5c8026745cccd77fc6f71819fe6e8 Mon Sep 17 00:00:00 2001 From: Vardges Hovhannisyan <43929589+VkoHov@users.noreply.github.com> Date: Tue, 17 May 2022 18:59:56 +0400 Subject: [PATCH] [fix] Change Uint16Array to Uint8Array in stringToArrayBuffer method (#1756) * [fix] Change Uint16Array to Uint8Array in stringToArrayBuffer method --- aim/web/ui/src/services/live-update/utils.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/aim/web/ui/src/services/live-update/utils.ts b/aim/web/ui/src/services/live-update/utils.ts index 0099cdcc3c..d7af4cdb9c 100644 --- a/aim/web/ui/src/services/live-update/utils.ts +++ b/aim/web/ui/src/services/live-update/utils.ts @@ -58,7 +58,7 @@ export function createGetStream( * @returns String. */ function arrayBufferToString(buffer: ArrayBuffer): string { - return String.fromCharCode.apply(null, Array.from(new Uint16Array(buffer))); + return String.fromCharCode.apply(null, Array.from(new Uint8Array(buffer))); } /** @@ -69,12 +69,12 @@ function arrayBufferToString(buffer: ArrayBuffer): string { */ function stringToArrayBuffer(str: string): ArrayBuffer { const stringLength = str.length; - const buffer = new ArrayBuffer(stringLength * 2); - const bufferView = new Uint16Array(buffer); + const buffer = new ArrayBuffer(stringLength); + const bufferView = new Uint8Array(buffer); for (let i = 0; i < stringLength; i++) { bufferView[i] = str.charCodeAt(i); } - return buffer; + return bufferView; } /**