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

Function createAsyncIterable

packages/ai-openrouter/tests/usage-extraction.test.ts:28–43  ·  view source on GitHub ↗
(chunks: Array<T>)

Source from the content-addressed store, hash-verified

26 createOpenRouterText('openai/gpt-4o-mini', 'test-key')
27
28function createAsyncIterable<T>(chunks: Array<T>): AsyncIterable<T> {
29 return {
30 [Symbol.asyncIterator]() {
31 let index = 0
32 return {
33 // eslint-disable-next-line @typescript-eslint/require-await
34 async next() {
35 if (index < chunks.length) {
36 return { value: chunks[index++]!, done: false }
37 }
38 return { value: undefined as T, done: true }
39 },
40 }
41 },
42 }
43}
44
45describe('OpenRouter usage extraction', () => {
46 beforeEach(() => {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected