MCPcopy Create free account
hub / github.com/ampproject/amphtml / bytesToString

Function bytesToString

third_party/subscriptions-project/swg.js:3176–3184  ·  view source on GitHub ↗

* Converts a 8-bit bytes array into a string * @param {!Uint8Array} bytes * @return {string}

(bytes)

Source from the content-addressed store, hash-verified

3174 * @return {string}
3175 */
3176function bytesToString(bytes) {
3177 // Intentionally avoids String.fromCharCode.apply so we don't suffer a
3178 // stack overflow. #10495, https://jsperf.com/bytesToString-2
3179 const array = new Array(bytes.length);
3180 for (let i = 0; i < bytes.length; i++) {
3181 array[i] = String.fromCharCode(bytes[i]);
3182 }
3183 return array.join('');
3184}
3185
3186/**
3187 * Interpret a byte array as a UTF-8 string.

Callers 3

utf8DecodeSyncFunction · 0.70
base64UrlEncodeFromBytesFunction · 0.70
createPair_Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected