engelmi / ts-aspect

A simplistic library for Aspect Oriented Programming (AOP) in TypeScript.
https://www.npmjs.com/package/ts-aspect
GNU General Public License v3.0
15 stars 5 forks source link

Short-Circuit for Pre-Execution Contexts #14

Open DsMaccy opened 3 months ago

DsMaccy commented 3 months ago

Please describe what you would like to see

For the Advice.Before and Around aspects, I would like to be able to tell the aspected method to skip its execution. This will allow me to use pre and post invariants.

Please describe the solution you'd like

I would imagine that this would be doable by using the context. By exposing a mutable shortCircuit flag defaulted to false but settable to true, the call within the proxyFunc can be skipped.

engelmi commented 3 months ago

Hi @DsMaccy, Could you provide a detailed example? If I understood it correctly, then you could also apply the aspects to a (empty) mock of the function.