function base64(u8) {
  // Note: btoa has the worst API, and even mentioning Buffer here will
  // cause rollup to suck it in.

  // See RFC4648, sec. 4.
  // https://datatracker.ietf.org/doc/html/rfc4648#section-4
  const A = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  const rem = u8.length % 3;
  const len = u8.length - rem;
  let res = "";

  for (let i = 0; i < len; i += 3) {
    res += A[u8[i] >> 2];
    res += A[((u8[i] & 0x3) << 4) | (u8[i + 1] >> 4)];
    res += A[((u8[i + 1] & 0xf) << 2) | (u8[i + 2] >> 6)];
    res += A[u8[i + 2] & 0x3f];
  }
  if (rem === 1) {
    res += A[u8[len] >> 2];
    res += A[(u8[len] & 0x3) << 4];
    res += "==";
  } else if (rem === 2) {
    res += A[u8[len] >> 2];
    res += A[((u8[len] & 0x3) << 4) | (u8[len + 1] >> 4)];
    res += A[(u8[len + 1] & 0xf) << 2];
    res += "=";
  }

  return res;
}
/**
 * Base64 encode a Uint8Array.  Needed for browser compatibility where
 * the Buffer class is not available.
 *
 * @param {Uint8Array} u8 Bytes to encode
 * @returns {string} Base64 encoded string
 */
Base64 encode a Uint8Array.  Needed for browser compatibility where
the Buffer class is not available.

@param {Uint8Array} u8 Bytes to encode
@returns {string} Base64 encoded string
Base64 encode a Uint8Array . Needed for browser compatibility where the Buffer class is not available . @param { Uint8Array } u8 Bytes to encode @returns { string } Base64 encoded string
function base64(u8) {
  const A = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  const rem = u8.length % 3;
  const len = u8.length - rem;
  let res = "";
  for (let i = 0; i < len; i += 3) {
    res += A[u8[i] >> 2];
    res += A[((u8[i] & 0x3) << 4) | (u8[i + 1] >> 4)];
    res += A[((u8[i + 1] & 0xf) << 2) | (u8[i + 2] >> 6)];
    res += A[u8[i + 2] & 0x3f];
  }
  if (rem === 1) {
    res += A[u8[len] >> 2];
    res += A[(u8[len] & 0x3) << 4];
    res += "==";
  } else if (rem === 2) {
    res += A[u8[len] >> 2];
    res += A[((u8[len] & 0x3) << 4) | (u8[len + 1] >> 4)];
    res += A[(u8[len + 1] & 0xf) << 2];
    res += "=";
  }
  return res;
}
function base64 ( u8 ) { const A = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ; const rem = u8 . length % 3 ; const len = u8 . length - rem ; let res = "" ; for ( let i = 0 ; i < len ; i += 3 ) { res += A [ u8 [ i ] >> 2 ] ; res += A [ ( ( u8 [ i ] & 0x3 ) << 4 ) | ( u8 [ i + 1 ] >> 4 ) ] ; res += A [ ( ( u8 [ i + 1 ] & 0xf ) << 2 ) | ( u8 [ i + 2 ] >> 6 ) ] ; res += A [ u8 [ i + 2 ] & 0x3f ] ; } if ( rem === 1 ) { res += A [ u8 [ len ] >> 2 ] ; res += A [ ( u8 [ len ] & 0x3 ) << 4 ] ; res += "==" ; } else if ( rem === 2 ) { res += A [ u8 [ len ] >> 2 ] ; res += A [ ( ( u8 [ len ] & 0x3 ) << 4 ) | ( u8 [ len + 1 ] >> 4 ) ] ; res += A [ ( u8 [ len + 1 ] & 0xf ) << 2 ] ; res += "=" ; } return res ; }
Base64 encode a Uint8Array.
Base64 encode a Uint8Array .
// Note: btoa has the worst API, and even mentioning Buffer here will // cause rollup to suck it in. // See RFC4648, sec. 4. // https://datatracker.ietf.org/doc/html/rfc4648#section-4