UNPKG

@emailcheck/email-validator-js

Version:

Advanced email validation with MX records, SMTP verification, disposable email detection, batch processing, and caching. Production-ready with TypeScript support.

25 lines (24 loc) 1.35 kB
/** * Lightweight transcript collector used by `verifyEmail` to capture a * structured trace of every subsystem call (syntax / disposable / free / * MX / SMTP / WHOIS / name detection / domain suggestion). * * Two collectors: * - `ArrayTranscriptCollector` — accumulates steps, exposed in result. * - `NULL_COLLECTOR` — no-op singleton used when capture is disabled, so * the call sites in `verifyEmail` never need an `if (transcript)` branch. */ import type { VerificationStep, VerificationStepKind } from './types'; export interface TranscriptCollector { /** Run `fn`, time it, push a step record. Re-throws on error after recording. */ record<T>(kind: VerificationStepKind, fn: () => Promise<T> | T, detailsFor: (value: T) => Record<string, unknown>): Promise<T>; /** Push a pre-built step. Useful when timing is owned by the callee. */ push(step: VerificationStep): void; } export declare class ArrayTranscriptCollector implements TranscriptCollector { readonly steps: VerificationStep[]; record<T>(kind: VerificationStepKind, fn: () => Promise<T> | T, detailsFor: (value: T) => Record<string, unknown>): Promise<T>; push(step: VerificationStep): void; } /** No-op collector — every method is a no-op. Used when capture is disabled. */ export declare const NULL_COLLECTOR: TranscriptCollector;