src/utils/bytes.js
/**
 * Converts a string which holds 8-bit code points, such as the result of atob,
 * into a Uint8Array with the corresponding bytes.
 * If you have a string of characters, you probably want to be using utf8Encode.
 * @param {string} str
 * @return {!Uint8Array}
 */
Converts a string which holds 8-bit code points, such as the result of atob,
into a Uint8Array with the corresponding bytes.
If you have a string of characters, you probably want to be using utf8Encode.
@param {string} str
@return {!Uint8Array}
Converts a string which holds 8 - bit code points such as the result of atob into a Uint8Array with the corresponding bytes . If you have a string of characters you probably want to be using utf8Encode . @param { string } str @return { !Uint8Array }
function stringToBytes(str) {
  const bytes = new Uint8Array(str.length);
  for (let i = 0; i < str.length; i++) {
    const charCode = str.charCodeAt(i);
    dev().assert(charCode <= 255, 'Characters must be in range [0,255]');
    bytes[i] = charCode;
  }
  return bytes;
}
function stringToBytes ( str ) { const bytes = new Uint8Array ( str . length ) ; for ( let i = 0 ; i < str . length ; i ++ ) { const charCode = str . charCodeAt ( i ) ; dev ( ) . assert ( charCode <= 255 , 'Characters must be in range [0,255]' ) ; bytes [ i ] = charCode ; } return bytes ; }
Converts a string which holds 8-bit code points, such as the result of atob,
 into a Uint8Array with the corresponding bytes.
Converts a string which holds 8 - bit code points such as the result of atob into a Uint8Array with the corresponding bytes .