Documentation
    Preparing search index...

    Function encodeBase64

    • Encodes bytes as standard, padded base64 (RFC 4648 §4).

      Written out by hand rather than delegating, on purpose: Buffer does not exist in a browser and would drag a Node dependency into a package that must run in both, while btoa only accepts a string of code units ≤ 255 — feeding it a large buffer means first materialising that string, which is exactly the spread-the-arguments pattern that blows the call stack on real snapshots. Sixteen lines of table lookup have neither problem and are identical on every runtime, which is what §33 wants from anything on the replay path.

      Output is built in chunks and joined once, so encoding an N-byte buffer costs O(N) and holds at most one chunk of intermediate string at a time.

      Parameters

      • buffer: ArrayBuffer

        bytes to encode

      Returns string

      the base64 text ("" for an empty buffer)

      encodeBase64(new TextEncoder().encode("foobar").buffer); // "Zm9vYmFy"