MCPcopy Create free account
hub / github.com/Noumena-Network/code / collectStream

Function collectStream

src/query/stopHooks.test.ts:104–116  ·  view source on GitHub ↗
(
  stream: AsyncGenerator<unknown, T>,
)

Source from the content-addressed store, hash-verified

102}
103
104async function collectStream<T>(
105 stream: AsyncGenerator<unknown, T>,
106): Promise<{ events: unknown[]; terminal: T }> {
107 const events: unknown[] = []
108
109 while (true) {
110 const next = await stream.next()
111 if (next.done) {
112 return { events, terminal: next.value }
113 }
114 events.push(next.value)
115 }
116}
117
118beforeEach(() => {
119 stopHookResults.length = 0

Callers 1

stopHooks.test.tsFile · 0.85

Calls 1

nextMethod · 0.45

Tested by

no test coverage detected