MCPcopy Create free account
hub / github.com/Rfym21/Qwen2API / readStreamBody

Function readStreamBody

src/controllers/cli.chat.js:181–197  ·  view source on GitHub ↗

* 读取流响应体为文本 * @param {*} stream - 响应流 * @returns {Promise } 文本结果

(stream)

Source from the content-addressed store, hash-verified

179 * @param {*} stream - 响应流
180 * @returns {Promise<string>} 文本结果
181 */
182function readStreamBody(stream) {
183 return new Promise((resolve, reject) => {
184 if (!stream || typeof stream.on !== 'function') {
185 resolve('')
186 return
187 }
188
189 const chunks = []
190 stream.on('data', (chunk) => {
191 chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk)))
192 })
193 stream.on('end', () => {
194 resolve(Buffer.concat(chunks).toString('utf8'))
195 })
196 stream.on('error', reject)
197 })
198}
199
200/**

Callers 1

normalizeCliErrorDetailsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected