AspectJS
Supporting AOP in JavaScript.
Installation
Node.JS
var aspect = ;
Browser
Import by <script>
tag. aspect
is then attached to window
.
APIs
context
, method
, advice
)
aspect.before(Run advice
before the execution of method
of context
.
e.g.:
// In browser.var { return id + ': Example';} aspect;
context
, method
, advice
)
aspect.after(Run advice
after the execution of method
of context
no matter if method
is returned normally or has thrown an exception.
e.g.:
// In browser.var { console; if age > 26 throw 'Big age :-)'; return '[' + age + ']';}; aspect;
context
, method
, advice
)
aspect.afterReturn(Run advice
after the execution of method
of context
only if method
is returned normally.
e.g.:
// In browser.var { console; if age > 26 throw 'Big age :-)'; return '[' + age + ']';}; aspect;
context
, method
, advice
)
aspect.afterThrow(Run advice
after the execution of method
of context
only if method
has thrown an exception.
e.g.:
// In browser.var { console; if age > 26 throw 'Big age :-)'; return '[' + age + ']';}; aspect;
context
, method
, advice
)
aspect.around(Surrounds method
of context
with advice
.
advice
will automatically received a copy of the original function as its first parameter.
e.g.:
// In browser.var { console; if age > 26 throw 'Big age :-)'; return '[' + age + ']';}; aspect;
License
MIT