export interface AdvisingFunction extends Function { /** * The next advice in an advice chain */ readonly next: AdvisingFunction; /** * The previous advice in an advice chain */ readonly previous: AdvisingFunction; } export interface DispatchAdvice { before?: BeforeAdvice[]; after?: AfterAdvice[]; readonly joinPoint: Function; } export interface BeforeAdvice { /** * Advice which is applied *before*, receiving the original arguments, if the advising * function returns a value, it is passed further along taking the place of the original * arguments. * * @param args The arguments the method was called with */ (...args: any[]): any[] | void; } export interface AfterAdvice { /** * Advice which is applied *after*, receiving the result and arguments from the join point. * * @param result The result from the function being advised * @param args The arguments that were supplied to the advised function * @returns The value returned from the advice is then the result of calling the method */ (result: T, ...args: any[]): T; } export interface AroundAdvice { /** * Advice which is applied *around*. The advising function receives the original function and * needs to return a new function which will then invoke the original function. * * @param origFn The original function * @returns A new function which will inoke the original function. */ (origFn: GenericFunction): (...args: any[]) => T; } /** * Types of advice */ export declare enum AdviceType { Before = 0, After = 1, Around = 2, } export interface GenericFunction { (...args: any[]): T; } /** * Apply advice *before* the supplied joinPoint (function) * * @param joinPoint A function that should have advice applied to * @param advice The before advice */ export declare function before>(joinPoint: F, advice: BeforeAdvice): F; /** * Apply advice *after* the supplied joinPoint (function) * * @param joinPoint A function that should have advice applied to * @param advice The after advice */ export declare function after, T>(joinPoint: F, advice: AfterAdvice): F; /** * Apply advice *around* the supplied joinPoint (function) * * @param joinPoint A function that should have advice applied to * @param advice The around advice */ export declare function around, T>(joinPoint: F, advice: AroundAdvice): F;