Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

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

Deno build of the official Typescript library for the OpenAI API.
Extremely Popular
Go to Latest
method AbstractChatCompletionRunner.prototype.emitted
import { AbstractChatCompletionRunner } from "https://deno.land/x/openai@v4.21.0/lib/AbstractChatCompletionRunner.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 Events

Returns

Promise<EventParameters<Events, Event> extends [infer Param] ? Param : EventParameters<Events, Event> extends [] ? void : EventParameters<Events, 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