Skip to content

SimulateReadableStream

Namespace: Vercel.AI.Util

public static class SimulateReadableStream

Emits scripted chunks, optionally delaying each pull.

Inheritance: object

View source

Create<T>(IReadOnlyList<T>, int?, int?, Func<int?, Task>?)

Section titled “Create<T>(IReadOnlyList<T>, int?, int?, Func<int?, Task>?)”
public static ReadableStream<T> Create<T>(IReadOnlyList<T> chunks, int? initialDelayInMs = 0, int? chunkDelayInMs = 0, Func<int?, Task>? delay = null)

Creates a stream of <code class=“paramref”>chunks</code>. A null delay skips the wait. 0 still invokes the delay with zero.

Type parameters

Name Description
T

Parameters

Name Type Description
chunks IReadOnlyList<T>
initialDelayInMs int?
chunkDelayInMs int?
delay Func<int?, Task>

Returns: ReadableStream&lt;T&gt;

View source

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