MCPcopy Create free account
hub / github.com/denoland/std / flush

Method flush

http/server_sent_event_parse_stream.ts:212–237  ·  view source on GitHub ↗
(controller)

Source from the content-addressed store, hash-verified

210 },
211
212 flush(controller) {
213 // Handle any remaining content in buffer
214 buffer += decoder.decode();
215
216 // Trailing \r at end of stream is a line ending
217 if (buffer[buffer.length - 1] === "\r") {
218 buffer = buffer.slice(0, -1);
219 if (parseLine(buffer, message, ignoreComments)) {
220 hasFields = true;
221 }
222 // The \r was a line ending, so dispatch if we have fields
223 if (hasFields) {
224 controller.enqueue(message);
225 return;
226 }
227 } else if (buffer) {
228 if (parseLine(buffer, message, ignoreComments)) {
229 hasFields = true;
230 }
231 }
232
233 // Dispatch final message if non-empty
234 if (hasFields) {
235 controller.enqueue(message);
236 }
237 },
238 });
239 }
240}

Callers

nothing calls this directly

Calls 2

parseLineFunction · 0.85
sliceMethod · 0.45

Tested by

no test coverage detected