UNPKG

ai-patterns

Version:

Production-ready TypeScript patterns to build solid and robust AI applications. Retry logic, circuit breakers, rate limiting, human-in-the-loop escalation, prompt versioning, response validation, context window management, and more—all with complete type

25 lines 758 B
/** * Throttle Pattern - Limit execution frequency */ import { ThrottleOptions, ThrottledFunction } from "../types/throttle"; /** * Define a throttled function * * @example * ```typescript * const trackEvent = defineThrottle({ * execute: async () => await analytics.track(), * interval: 1000 // Max once per second * }); * * trackEvent(); // Executes immediately * trackEvent(); // Throttled (skipped) * ``` */ export declare function defineThrottle<TArgs extends any[] = any[], TResult = any>(options: ThrottleOptions<TArgs, TResult>): ThrottledFunction<TArgs, TResult>; /** * @deprecated Use `defineThrottle` instead * @see defineThrottle */ export declare const throttle: typeof defineThrottle; //# sourceMappingURL=throttle.d.ts.map