import { asArray } from './as-array'; /** * A callback function that can be used to notify listeners. */ export type Listener = (event: EVENT) => PromiseLike | void; /** * Notifies all provided callbacks with the given event. * Errors in callbacks do not break the generation flow. */ export async function notify(options: { event: EVENT; callbacks?: Listener | Array | undefined | null>; }): Promise { for (const callback of asArray(options.callbacks)) { if (callback == null) continue; try { await callback(options.event); } catch (_ignored) {} } }