btoa = stringToEncode => {
  const bytes = stringToEncode.split('').map(char => {
    const b = char.charCodeAt(0);
    if (b > 0xff) {
      throw Error(`btoa: character out of range: ${char}`);
    }
    return b;
  });
  const buf = new Uint8Array(bytes);
  return encodeBase64(buf);
}
@param {string} stringToEncode the binary string to encode
@returns {string} an ASCII string containing the base64 representation of `stringToEncode`