/** * A function that can be added via a Middleware Container's `use` function. * `previous` will be the value that passed from the previous Middleware function in the 'stack'. * `next` is a reference to the next Middleware function in the 'stack'. * * @example * // No-op * container.use((x, next) => next(x)) * * @example * // Tap input/output * container.use((x, next) => { * console.log('input', x); * const result = next(x); * console.log('output', result); * return result * }) * * @example * // Mutate input * container.use((x, next) => next({ * ...x, * extraProp: true * })) * * @example * // Mutate output * container.use((x, next) => ({ * ...next(x), * extraProp: true * })) * * @example * // Short-circuit/Branching * container.use((x, next) => x.authenticated ? next(x) : 'Access Denied') */ export declare type MiddlewareFn = (previous: T, next: NextFn) => U; /** * A reference to the 'next' function in the Middleware stack. */ export declare type NextFn = (value: T) => U; /** * Used to 'add' another function to the Middleware stack. */ export declare type UseFn = (middleware: MiddlewareFn) => void; /** * A Middleware container provides an encapsulation for Middleware functions to be 'registered' via `use`, and then * applied when required via `apply`. */ export declare type Container = { use: UseFn; apply: NextFn; }; /** * Creates a Middleware container. Requires an initial implementation function via `initial`. New Middleware functions * may be added via `use`, and the result of calling the entire stack via `apply`. */ export declare const makeContainer: (initial: NextFn) => Container; //# sourceMappingURL=middleware.d.ts.map