lucacasonato / proposal-binary-encoding

A proposal to add modern, easy to use binary encoders to the web platform.
Other
40 stars 1 forks source link

`buffer` and `bytes` mixed in example #9

Open appsforartists opened 1 year ago

appsforartists commented 1 year ago
/**
 * @param {Uint8Array} bytes
 * @returns {string}
 */
function base64Encode(bytes) {
  var binary = "";
  var bytes = new Uint8Array(buffer);
  var len = bytes.byteLength;
  for (var i = 0; i < len; i++) {
    binary += String.fromCharCode(bytes[i]);
  }
  return globalThis.btoa(binary);
}

You use bytes as both an argument name and a local var name, but don't define buffer. I believe this is a typo.