ai-tube / src /huggingface /shared /base64FromBytes.ts
jbilcke-hf's picture
jbilcke-hf HF staff
🍿
1f122c3
raw
history blame
No virus
297 Bytes
export function base64FromBytes(arr: Uint8Array): string {
if (globalThis.Buffer) {
return globalThis.Buffer.from(arr).toString("base64");
} else {
const bin: string[] = [];
arr.forEach((byte) => {
bin.push(String.fromCharCode(byte));
});
return globalThis.btoa(bin.join(""));
}
}