code: function btoa(bin) {
          for (var i = 0, j = 0, len = bin.length / 3, base64 = []; i < len; ++i) {
              var a = bin.charCodeAt(j++),
                  b = bin.charCodeAt(j++),
                  c = bin.charCodeAt(j++);
              if ((a | b | c) > 255) throw new Error("String contains an invalid character");
              base64[base64.length] = table[a >> 2] + table[((a << 4) & 63) | (b >> 4)] +
                  (isNaN(b) ? "=" : table[((b << 2) & 63) | (c >> 6)]) +
                  (isNaN(b + c) ? "=" : table[c & 63]);
          }
          return base64.join("");
      }
docs: btoa
  @private