@nweb/core
Advanced tools
@@ -75,3 +75,3 @@ export declare function Readonly(target: any, property: any, descriptor: any): any; | ||
| before(target: any, method: string, args: any[]): any; | ||
| after(target: any, method: string, args: any[], result: any): void; | ||
| after(target: any, method: string, args: any[], result: any): Promise<void>; | ||
| } | ||
@@ -78,0 +78,0 @@ export declare function Aspect(point: { |
@@ -244,3 +244,3 @@ "use strict"; | ||
| } | ||
| after(target, method, args, result) { | ||
| async after(target, method, args, result) { | ||
| if (this.type === 'after') { | ||
@@ -247,0 +247,0 @@ this.component[this.handle]?.call(target, method, args, result); |
+9
-9
@@ -277,10 +277,10 @@ "use strict"; | ||
| async apply(method, thisArg, args) { | ||
| const aspects = self.aspects.filter(aspect => aspect.match(target, p)); | ||
| const beforeList = await Promise.all(aspects.map(aspect => aspect.before(target, p, args))); | ||
| if (beforeList.includes(false)) { | ||
| return; | ||
| const [aspect] = self.aspects.filter(aspect => aspect.match(target, p)); | ||
| let beforeReturn = await aspect?.before(target, p, args); | ||
| if (beforeReturn !== undefined) { | ||
| if (logger.isDebugEnabled()) { | ||
| logger.debug(`Component ${thisArg.annotation.name}#${p}(${(args || []).map((e, i) => `arg${i}`).join(', ')}) aspect before trigger`); | ||
| } | ||
| return beforeReturn; | ||
| } | ||
| else if (logger.isDebugEnabled()) { | ||
| logger.debug(`Component ${thisArg.annotation.name}#${p}(${(args || []).map((e, i) => `arg${i}`).join(', ')}) aspect before trigger`); | ||
| } | ||
| const result = await method.apply(thisArg, args); | ||
@@ -290,5 +290,5 @@ if (logger.isDebugEnabled()) { | ||
| } | ||
| let afterList = await Promise.all(aspects.map(aspect => aspect.after(target, p, args, result))); | ||
| if (afterList.length && logger.isDebugEnabled()) { | ||
| if (aspect) { | ||
| logger.debug(`Component ${thisArg.annotation.name}#${p}(${(args || []).map((e, i) => `arg${i}`).join(', ')}) aspect after trigger`); | ||
| await aspect.after(target, p, args, result); | ||
| } | ||
@@ -295,0 +295,0 @@ return result; |
+1
-1
| { | ||
| "name": "@nweb/core", | ||
| "version": "1.1.10", | ||
| "version": "1.1.11", | ||
| "description": "web核心组件", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index", |
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
145795
-0.06%