Skip to content

throttleStream

throttleStream(stream, intervalMs): IRChatStream

Defined in: streaming.ts:1002

Create a throttled version of a stream that limits how often chunks are yielded. Batches content chunks that arrive faster than the interval. Unlike rateLimitStream, this merges content chunks rather than delaying them.

IRChatStream

The source stream

number

Minimum milliseconds between yields

IRChatStream

// Update UI at most every 50ms
for await (const chunk of throttleStream(stream, 50)) {
updateUI(chunk);
}