MCPcopy
hub / github.com/socketio/socket.io / concatChunks

Function concatChunks

packages/engine.io-parser/lib/index.ts:87–104  ·  view source on GitHub ↗
(chunks: Uint8Array[], size: number)

Source from the content-addressed store, hash-verified

85}
86
87function concatChunks(chunks: Uint8Array[], size: number) {
88 if (chunks[0].length === size) {
89 return chunks.shift();
90 }
91 const buffer = new Uint8Array(size);
92 let j = 0;
93 for (let i = 0; i < size; i++) {
94 buffer[i] = chunks[0][j++];
95 if (j === chunks[0].length) {
96 chunks.shift();
97 j = 0;
98 }
99 }
100 if (chunks.length && j < chunks[0].length) {
101 chunks[0] = chunks[0].slice(j);
102 }
103 return buffer;
104}
105
106const enum State {
107 READ_HEADER,

Callers 1

transformFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected