Skip to content

AsyncIterableStreams

Namespace: Vercel.AI.Util

public static class AsyncIterableStreams

Wraps readable streams so they can be consumed with async iteration.

Inheritance: object

View source

AsAsyncIterableStream<T>(ReadableStream<T>)

Section titled “AsAsyncIterableStream<T>(ReadableStream<T>)”
public static AsyncIterableStream<T> AsAsyncIterableStream<T>(ReadableStream<T> stream)

Attaches an async iterator to <code class=“paramref”>stream</code> without inserting another transform.

Type parameters

Name Description
T

Parameters

Name Type Description
stream ReadableStream&lt;T&gt;

Returns: AsyncIterableStream&lt;T&gt;

View source

CreateAsyncIterableStream<T>(ReadableStream<T>)

Section titled “CreateAsyncIterableStream<T>(ReadableStream<T>)”
public static AsyncIterableStream<T> CreateAsyncIterableStream<T>(ReadableStream<T> source)

Pipes <code class=“paramref”>source</code> through an identity transform and returns an async iterable. Cancelling the result cancels <code class=“paramref”>source</code>.

Type parameters

Name Description
T

Parameters

Name Type Description
source ReadableStream&lt;T&gt;

Returns: AsyncIterableStream&lt;T&gt;

View source

Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product