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 }