properly handle subarray messages

This commit is contained in:
Toshit Chawda 2024-09-03 17:36:51 -07:00
parent f90d159fac
commit 172c5a3ee6
No known key found for this signature in database
GPG key ID: 91480ED99E2B3D9D

View file

@ -338,8 +338,8 @@ export class BareClient {
if (error) throw error; if (error) throw error;
let data = args[0]; let data = args[0];
// @ts-expect-error idk why it errors? // @ts-expect-error
if (data.buffer) data = data.buffer; if (data.buffer) data = data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
channel.port1.postMessage({ type: "data", data: data }, data instanceof ArrayBuffer ? [data] : []); channel.port1.postMessage({ type: "data", data: data }, data instanceof ArrayBuffer ? [data] : []);
}; };