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:
parent
4082f96ebd
commit
23aad51699
12
src/utils/converters.util.ts
Normal file
12
src/utils/converters.util.ts
Normal 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;
|
Loading…
x
Reference in New Issue
Block a user