File tree Expand file tree Collapse file tree 1 file changed +8
-11
lines changed
Expand file tree Collapse file tree 1 file changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -8,20 +8,17 @@ class Complexity<PostType> implements instamancer.IPlugin<PostType> {
88 this . query = query ;
99 }
1010
11- public responseEvent (
11+ public async responseEvent (
1212 this : instamancer . IPluginContext < Complexity < PostType > , PostType > ,
1313 res : Response ,
1414 data : { [ key : string ] : any } ,
15- ) : void {
16- this . state . page
17- . evaluate ( ( query ) => {
18- return document . querySelectorAll ( query ) . length ;
19- } , this . plugin . query )
20- . then ( ( count ) => {
21- process . stdout . write (
22- `${ this . plugin . query } elements: ${ count } \n` ,
23- ) ;
24- } ) ;
15+ ) : Promise < void > {
16+ const elementCount = await this . state . page . evaluate ( ( query ) => {
17+ return document . querySelectorAll ( query ) . length ;
18+ } , this . plugin . query ) ;
19+ process . stdout . write (
20+ `${ this . plugin . query } elements: ${ elementCount } \n` ,
21+ ) ;
2522 }
2623}
2724
You can’t perform that action at this time.
0 commit comments