Skip to content
Discussion options

You must be logged in to vote

I figured out I can do this:

const getStream = (text: string) => {
    const encoder = new TextEncoder();
    const encodedChunk = encoder.encode(text);
    return new ReadableStream({
        start(controller) {
            controller.enqueue(encodedChunk);
            controller.close();
        }
    });
}

Let me know if there are better way to send errors.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by spy16
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
1 participant