add client receiving base

This commit is contained in:
2025-05-04 14:17:20 +02:00
parent fbbaabb04b
commit 194fd2adea
9 changed files with 228 additions and 2 deletions

13
client/tools.ts Normal file
View File

@@ -0,0 +1,13 @@
/**
* Convert big-endian u32 to native JavaScript number.
*/
export function uint_bytes_to_num(value: Uint8Array): number {
if (value.length != 4) { throw new Error("can't convert non 4-byte integer"); }
const data_view = new DataView(value.buffer);
return data_view.getUint32(0, false);
}
export function utf8_decode(value: Uint8Array): string {
const decoder = new TextDecoder("utf-8");
return decoder.decode(value);
}