import type { AnyTypeGuard } from './types'; type LogGuard = (guard: Guard, before?: ({ value, guard }: { readonly value: unknown; readonly guard: Guard; }) => void, after?: ({ result, value, guard }: { readonly result: boolean; readonly value: unknown; readonly guard: Guard; }) => void) => Guard; /** * Given a Type Guard, returns a Type Guard that does exactly the same but logs the `guard`, `value` before calling guard(value). Logs result after. * Equivalent of {@linkcode hookGuard}, but uses `console.log` for the before and after hook by default. * * @example * ```ts * import { logGuard, isNull } from 'type-guard-helpers' * const test = {} as string | null; * if (logGuard(isNull)(test)) { * test; // null * } * // hooking to log * const hookLog = hookGuard( * isNull, * ({value, guard}) => console.info(`Calling:`, { guard, value }), * ({result}) => console.info(`Result:`, { result }) * ); * ``` * @category Type Guard Debugger */ declare const logGuard: LogGuard; export { logGuard }; export type { LogGuard };