如何安装
npm install node-aspect
如何使用
moduleexexports = { console; return name; }//importconst Aspect = ;// create Aspectlet aspect = '/**/test/**/*.js' `classes` `name`;//set [before, after, error, around] handleraspect;//start aopaspect; const Hello = ;console; // output:before: Alonehello AloneAlone
API
type
, handler
)
handler(Set handler.
-
type
- (String) aop handler type:before
- (String) target method before called.after
- (String) target method after return called.error
- (String) target method error called.around
- (String) target method around called.
-
handler
- (Function) aop handler function:before
- {function(arguments
)} last arg is this Aspect.after
- {function(arguments
+this Aspect
+ctx
+result
)} last arg is this Aspect.error
- {function(arguments
+this Aspect
+ctx
+error
)} last arg is this Aspect.around
- {function(arguments
)} last arg is this Aspect.
Return this
aop()
start aop.