MCPcopy
hub / github.com/FoalTS/foal / streamToBuffer

Function streamToBuffer

packages/core/src/common/utils/stream-to-buffer.ts:8–15  ·  view source on GitHub ↗
(stream: NodeJS.ReadableStream)

Source from the content-addressed store, hash-verified

6 * @returns {Promise<Buffer>} The concatenated buffer
7 */
8export async function streamToBuffer(stream: NodeJS.ReadableStream): Promise<Buffer> {
9 return await new Promise((resolve, reject) => {
10 const chunks: Buffer[] = [];
11 stream.on('data', (chunk: Buffer) => chunks.push(chunk));
12 stream.on('error', reject);
13 stream.on('end', () => resolve(Buffer.concat(chunks)));
14 });
15}

Callers 7

testAssetFunction · 0.90
hookFunction · 0.90
readMethod · 0.90
testAssetFunction · 0.90

Calls 1

pushMethod · 0.80

Tested by 2

testAssetFunction · 0.72
testAssetFunction · 0.72