Skip to main content
Module

x/openai/lib/EventStream.ts>EventStream#emitted

Deno build of the official Typescript library for the OpenAI API.
Extremely Popular
Go to Latest
method EventStream.prototype.emitted
import { EventStream } from "https://deno.land/x/openai@v4.58.1/lib/EventStream.ts";

This is similar to .once(), but returns a Promise that resolves the next time the event is triggered, instead of calling a listener callback.

Type Parameters

Event extends keyof EventTypes

Returns

Promise<EventParameters<EventTypes, Event> extends [infer Param] ? Param : EventParameters<EventTypes, Event> extends [] ? void : EventParameters<EventTypes, Event>>

a Promise that resolves the next time given event is triggered, or rejects if an error is emitted. (If you request the 'error' event, returns a promise that resolves with the error).

Example:

const message = await stream.emitted('message') // rejects if the stream errors