MCPcopy Create free account
hub / github.com/astercloud/aster / pump

Function pump

examples/plan-explore-ui/static/main.js:80–105  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

78 const uiState = { currentPhase: null, textStarted: false };
79
80 function pump() {
81 reader
82 .read()
83 .then(({ done, value }) => {
84 if (done) {
85 setStatus("完成");
86 runBtn.disabled = false;
87 return;
88 }
89 buffer += decoder.decode(value, { stream: true });
90 let idx;
91 while ((idx = buffer.indexOf("\n\n")) >= 0) {
92 const raw = buffer.slice(0, idx);
93 buffer = buffer.slice(idx + 2);
94 handleSSEChunk(raw, uiState);
95 }
96 pump();
97 })
98 .catch((err) => {
99 if (err.name !== "AbortError") {
100 appendPhaseLine(`流式读取出错: ${err}`, "error");
101 setStatus("出错");
102 runBtn.disabled = false;
103 }
104 });
105 }
106
107 pump();
108 })

Callers 1

startRunFunction · 0.85

Calls 3

setStatusFunction · 0.85
handleSSEChunkFunction · 0.85
appendPhaseLineFunction · 0.85

Tested by

no test coverage detected