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

Function onDataChunk

packages/socket.io/lib/uws.ts:137–161  ·  view source on GitHub ↗
(chunk: Buffer)

Source from the content-addressed store, hash-verified

135 };
136
137 const onDataChunk = (chunk: Buffer) => {
138 const arrayBufferChunk = toArrayBuffer(chunk);
139
140 res.cork(() => {
141 const lastOffset = res.getWriteOffset();
142 const [ok, done] = res.tryEnd(arrayBufferChunk, size);
143
144 if (!done && !ok) {
145 readStream.pause();
146
147 res.onWritable((offset) => {
148 const [ok, done] = res.tryEnd(
149 arrayBufferChunk.slice(offset - lastOffset),
150 size,
151 );
152
153 if (!done && ok) {
154 readStream.resume();
155 }
156
157 return ok;
158 });
159 }
160 });
161 };
162
163 res.onAborted(destroyReadStream);
164 readStream

Callers

nothing calls this directly

Calls 3

toArrayBufferFunction · 0.85
corkMethod · 0.80
pauseMethod · 0.45

Tested by

no test coverage detected