diff options
| author | TheMas3212 <mas3212@gmail.com> | 2023-09-24 20:52:35 +1000 |
|---|---|---|
| committer | TheMas3212 <mas3212@gmail.com> | 2023-09-24 20:52:35 +1000 |
| commit | 24b8e412adc0bbecf1840280ed9b30bc131b7b8d (patch) | |
| tree | 8433b8cab9c1e7414fbb110a0cde27ee7101af4f | |
| parent | f40253cda125cb73fb7bdf923b22b3bfaa8f8f27 (diff) | |
| download | tasd-js-24b8e412adc0bbecf1840280ed9b30bc131b7b8d.tar.gz tasd-js-24b8e412adc0bbecf1840280ed9b30bc131b7b8d.zip | |
Add Helpers for Boolean values
| -rw-r--r-- | src/utils.ts | 7 |
1 files changed, 7 insertions, 0 deletions
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 |
