The async generator pattern
In Node 20+ and modern browsers, the ReadableStream from fetch().body + TextDecoder + a manual newline-buffer is the canonical way to consume Ollama's NDJSON. Wrapping it in an async function* generator turns the stream into something you can iterate with for await.
The buffer pattern (don't skip this)
Network chunks don't align with JSON lines. A single read() might return:
'{"a":1,"b":2}\n{"c":3,'— last line is incomplete'4}\n{"e":5}\n'— first part finishes the previous line
You must accumulate into a buffer, split on \n, parse all complete lines, and keep the partial tail in the buffer. This is the single most-bug-prone piece of TypeScript Ollama clients.