CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
emitAsync.ts26 linesDownload Raw Back to utils
1import { Emitter, EventMap } from 'strict-event-emitter'2 3/**4 * Emits an event on the given emitter but executes5 * the listeners sequentially. This accounts for asynchronous6 * listeners (e.g. those having "sleep" and handling the request).7 */8export async function emitAsync<9  Events extends EventMap,10  EventName extends keyof Events11>(12  emitter: Emitter<Events>,13  eventName: EventName,14  ...data: Events[EventName]15): Promise<void> {16  const listners = emitter.listeners(eventName)17 18  if (listners.length === 0) {19    return20  }21 22  for (const listener of listners) {23    await listener.apply(emitter, data)24  }25}26 
basant307/AI_Governance_Project · CoolFace