import { EventStream } from "https://deno.land/x/openai@v4.59.0/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.
Parameters
event: Event
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