UNPKG

typescript-event-emitter

Version:

Versatile and feature-rich TypeScript library for event management, providing a solid foundation for building event-driven applications in TypeScript.

45 lines (44 loc) 2.1 kB
import { EventNamespace } from './Interfaces'; import { AsyncListener, ThrottledListener } from './Types'; /** * Splits the given event string into namespace and event name parts. * @param {string} event - The event string to parse. * @param {string} separator - The separator used to split the event string. * @returns A tuple containing the namespace and event name. */ export declare const parseEvent: (event: string, separator: string) => [string, string]; /** * Inserts a listener object into a sorted array based on priority. * @param listeners - The array of listener objects to insert into. * @param listenerObject - The listener object to be inserted, containing the listener function and its priority. */ export declare const insertSorted: (listeners: { listener: ThrottledListener | AsyncListener; priority: number; }[], listenerObject: { listener: ThrottledListener | AsyncListener; priority: number; }) => void; /** * Checks if the provided object is empty (has no own enumerable properties). * @param obj - The object to check for emptiness. * @returns `true` if the object is empty; otherwise, `false`. */ export declare const isObjectEmpty: (obj: object) => boolean; /** * Gets the prioritized value, favoring a new value over a default value. * If a new value is provided and not empty, it is returned; otherwise, the default value is used. * @param defaultValue - The default value. * @param newValue - The potentially new value. * @returns The prioritized value. */ export declare const getPrioritizedValue: (defaultVal: string, newVal: string | undefined) => string; /** * Finds information about a specific event, including its separator and event name, * within the provided event namespaces. * * @param event - The name of the event for which information is to be retrieved. * @param eventNamespaces - A record containing namespaces and their associated events and listeners. * @returns separator from event information. */ export declare const findEventInfo: (event: string, eventNamespaces: Record<string, EventNamespace>) => string;