/** * Compose Pattern - Middleware-based composition */ import type { Middleware, ComposeConfig } from "../types/composition"; export type { Middleware, ComposeConfig }; /** * Compose multiple middlewares together * * Middlewares are applied from right to left (innermost first), similar to * function composition in mathematics: compose([f, g, h])(x) = f(g(h(x))) * * @example * ```typescript * import { compose, withTimeout, withRetry, withCircuitBreaker } from 'ai-patterns'; * * const robustAPI = compose([ * withCircuitBreaker({ failureThreshold: 5 }), * withTimeout({ duration: 5000 }), * withRetry({ maxAttempts: 3 }) * ]); * * const result = await robustAPI( * async () => fetch('/api/data').then(r => r.json()), * undefined * ); * ``` * * @param middlewares - Array of middlewares to compose * @param config - Optional configuration * @returns Composed function that applies all middlewares */ export declare function compose(middlewares: Middleware[], config?: ComposeConfig): (execute: (input: TInput) => TOutput | Promise, input?: TInput) => Promise; //# sourceMappingURL=compose.d.ts.map