Skip to content

teeStream

teeStream(stream, count): IRChatStream[]

Defined in: streaming.ts:1076

Split a stream into multiple streams that can be consumed independently. Each returned stream receives all chunks from the source. Alias for splitStream with a simpler interface.

IRChatStream

The source stream

number = 2

Number of streams to create

IRChatStream[]

const [stream1, stream2] = teeStream(originalStream, 2);
// Consume independently
const [result1, result2] = await Promise.all([
collectStreamFull(stream1),
processStream(stream2, { onContent: console.log }),
]);