From 24b8e412adc0bbecf1840280ed9b30bc131b7b8d Mon Sep 17 00:00:00 2001 From: TheMas3212 Date: Sun, 24 Sep 2023 20:52:35 +1000 Subject: Add Helpers for Boolean values --- src/utils.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/utils.ts b/src/utils.ts index f47f584..e4024f0 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -92,4 +92,11 @@ export function writeString(str: string, buffer: Uint8Array, index: number) { } export function encodeString(str: string) { return encoder.encode(str); +} + +export function readBoolean(buffer: Uint8Array, index: number) { + return buffer[index] !== 0; +} +export function writeBoolean(bool: boolean, buffer: Uint8Array, index: number) { + buffer[index] = bool ? 1 : 0; } \ No newline at end of file -- cgit v1.2.3