MCPcopy Create free account
hub / github.com/TanStack/ai / collectGeneratorOutput

Function collectGeneratorOutput

packages/ai/tests/tool-call-manager.test.ts:86–99  ·  view source on GitHub ↗
(
    generator: AsyncGenerator<TChunk, TResult, void>,
  )

Source from the content-addressed store, hash-verified

84 }
85
86 async function collectGeneratorOutput<TChunk, TResult>(
87 generator: AsyncGenerator<TChunk, TResult, void>,
88 ): Promise<{
89 chunks: Array<TChunk>
90 result: TResult
91 }> {
92 const chunks: Array<TChunk> = []
93 let next = await generator.next()
94 while (!next.done) {
95 chunks.push(next.value)
96 next = await generator.next()
97 }
98 return { chunks, result: next.value }
99 }
100
101 it('should accumulate tool call events', () => {
102 const manager = new ToolCallManager([mockWeatherTool])

Callers 1

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected