feat: Add converters utility file

This commit introduces a new utility file for various data conversions. This new file, converters.util.ts, includes functions to convert case for strings and convert between boolean values and buffers.
This commit is contained in:
Mathis H (Avnyr) 2024-05-15 11:44:11 +02:00
parent 4082f96ebd
commit 23aad51699
Signed by: Mathis
GPG Key ID: DD9E0666A747D126

View File

@ -0,0 +1,12 @@
const ConvertersUtils = {
toUpperCase: (str: string) => String(str).toUpperCase(),
toLowerCase: (str: string) => String(str).toLowerCase(),
bufferToBool: (buf: ArrayBuffer) => {
return new Uint8Array(buf)[0] !== 0;
},
boolToBuffer: (bol: boolean) => {
return new Uint8Array([bol ? 1 : 0]).buffer;
}
}
export default ConvertersUtils;