Aller au contenu principal

after()

after<In, Out>(hook): Decorator<In, Out>

Creates a decorator that runs a hook after the function executes.


Type Parameters

In: In

The input type

Out: Out

The output type


Parameters

hook: (input, output) => void

Function to run after, receives input and output


Returns: Decorator<In, Out>

A Decorator


Since

2.4.0


Example

const withAudit = after<number, number>((input, output) => {
auditLog.record({ input, output });
});

const double = withAudit((n) => n * 2);
double(5); // returns 10, audit log records { input: 5, output: 10 }