MCPcopy Create free account
hub / github.com/socketio/socket.io / onDataChunk

Function onDataChunk

lib/uws.ts:135–157  ·  view source on GitHub ↗
(chunk: Buffer)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

toArrayBufferFunction · 0.85
pauseMethod · 0.45

Tested by

no test coverage detected