MCPcopy
hub / github.com/google/brotli / bytesToString

Function bytesToString

js/decode_synth_test.ts:11–23  ·  view source on GitHub ↗

* NB: Use intermediate chunks to avoid "Maximum call stack size exceeded".

(bytes: Int8Array)

Source from the content-addressed store, hash-verified

9 * NB: Use intermediate chunks to avoid "Maximum call stack size exceeded".
10 */
11function bytesToString(bytes: Int8Array): string {
12 const kChunkSize = 4096;
13 if (bytes.length <= kChunkSize) {
14 const chars = new Uint8Array(bytes) as unknown as number[];
15 return String.fromCharCode.apply(null, chars);
16 }
17 const chunks = [];
18 for (let start = 0; start < bytes.length; start += kChunkSize) {
19 const end = Math.min(start + 4096, bytes.length);
20 chunks.push(bytesToString(bytes.slice(start, end)));
21 }
22 return chunks.join('');
23}
24
25/**
26 * NB: String.prototype.repeat causes "Maximum call stack size exceeded".

Callers 1

checkSynthFunction · 0.70

Calls 2

minMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…