@puregram/hear
Version:
simple implementation of hearing messages system for puregram
11 lines (10 loc) • 611 B
TypeScript
export type MaybeArray<T> = T | T[];
export interface ContextMatch {
$match: RegExpMatchArray | null;
}
export type HearFunctionCondition<T, V> = (value: V, context: T) => boolean;
export type HearCondition<T, V> = HearFunctionCondition<T, V> | RegExp | string | number | boolean;
export type HearObjectCondition<T extends Record<string, any>> = Record<string, MaybeArray<HearCondition<T, any>>> & {
[P in keyof T]?: MaybeArray<HearCondition<T, T[P]>>;
};
export type HearConditions<T extends Record<string, any>> = MaybeArray<HearCondition<T, string | undefined>> | MaybeArray<HearObjectCondition<T>>;