import { BasePipeline } from "./base-pipeline"; import { MiddlewareInterface } from "./interfaces"; /** * Pipeline is an inverted Monoid that stores an array of middleware functions to be applied to data passed as * pipeline.process() argument. * * **NOTE**: Pipeline creates a shallow copy of the context argument before passing it to the first middleware. */ export declare class Pipeline extends BasePipeline { /** * Pointer interface for lifting given middleware function to a Pipeline. * @param middleware - n Middleware functions. */ static of(middleware: MiddlewareInterface): Pipeline ? U : TResult, TReserved>; /** * Pointer interface for creating a Pipeline from array of Middleware. * @param middleware - Array of Middleware functions. */ static from(middleware: MiddlewareInterface[]): Pipeline; /** * Pointer interface for creating an empty Pipeline. */ static empty(): Pipeline; /** * Create new Pipeline containing Middleware functions of both current Pipeline and the Pipeline passed as an * argument. * @param o */ concat(o: Pipeline): Pipeline ? U : TNewResult, TReserved>; /** * Create a new Pipeline with Middleware provided as an argument appended to the end of the Middleware list. * @param middleware */ pipe(middleware: MiddlewareInterface): Pipeline ? U : TNewResult, TReserved>; /** * Sequentially call middleware functions stored inside Pipeline starting with context provided as an * argument. * * Values returned from middleware functions will be passed to the next middleware as an argument. * * If middleware that is currently being processed returns a Promise, it will be resolved before being passed to * the next middleware. * * Returns Promise of contents of the transformed context. If error occurs during execution, it can be caught with * returned Promise `.catch`. * * @param ctx */ process(ctx?: TReserved): Promise; }