11 lines
269 B
TypeScript
11 lines
269 B
TypeScript
export function decode(bytes: Uint8Array, encoding = 'utf8'): string {
|
|
const decoder = new TextDecoder(encoding);
|
|
return decoder.decode(bytes);
|
|
}
|
|
|
|
const encoder = new TextEncoder();
|
|
|
|
export function encode(str: string): Uint8Array {
|
|
return encoder.encode(str);
|
|
}
|