When working in Node.js, I can utilize the Buffer
class with both toString
variations and the base64Slice
method.
In JavaScript within a browser, the btoa
function is available for encoding.
Despite these native options, I am struggling to find a built-in conversion method in TypeScript without importing node type definitions. Is there a way to achieve this using only TypeScript?
My goal is to:
let plainTextString : string = "test"
let byteArrayUint : Uint8Array = new Uint8Array([74, 65, 73, 74])
let byteArrayArr : Array<number> = [74, 65, 73, 74]
method(any_variable)
any_variable.method()
Is it feasible to accomplish this? Any pointers would be greatly appreciated. Thank you.