MCPcopy Create free account
hub / github.com/cloudflare/agents / bytesToBase64

Function bytesToBase64

packages/shell/src/filesystem.ts:1545–1554  ·  view source on GitHub ↗
(bytes: Uint8Array)

Source from the content-addressed store, hash-verified

1543// ── Base64 helpers ───────────────────────────────────────────────────
1544
1545function bytesToBase64(bytes: Uint8Array): string {
1546 const CHUNK = 8192;
1547 let binary = "";
1548 for (let i = 0; i < bytes.byteLength; i += CHUNK) {
1549 binary += String.fromCharCode(
1550 ...bytes.subarray(i, Math.min(i + CHUNK, bytes.byteLength))
1551 );
1552 }
1553 return btoa(binary);
1554}
1555
1556function base64ToBytes(b64: string): Uint8Array {
1557 const binary = atob(b64);

Callers 1

writeFileBytesMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected