Skip to content

Commit 9e7a252

Browse files
refactor(MiddlewareBase): update the execute() and executeAsync() methods to comma separated.
1 parent 3cf5014 commit 9e7a252

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/lib/middleware-base.abstract.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ import { MiddlewareFunction } from '../type';
55
/**
66
* @description The base abstraction for arguments middleware.
77
* @export
8+
* @abstract
89
* @class MiddlewareBase
10+
* @typedef {MiddlewareBase}
911
* @template [T=any]
12+
* @template [O=T[]]
13+
* @template {Function} [U=MiddlewareFunction<T>]
14+
* @extends {MiddlewareCore<T, O, U>}
1015
*/
1116
export abstract class MiddlewareBase<
1217
T = any,
@@ -48,9 +53,9 @@ export abstract class MiddlewareBase<
4853
* @returns {this}
4954
*/
5055
public execute(...args: T[]) {
51-
this.#index = 0;
52-
this.#next(...args);
53-
return this;
56+
return this.#index = 0,
57+
this.#next(...args),
58+
this;
5459
}
5560

5661
/**
@@ -61,11 +66,10 @@ export abstract class MiddlewareBase<
6166
* @returns {unknown}
6267
*/
6368
public override async executeAsync(...args: T[]): Promise<O> {
64-
this.#index = 0;
65-
return new Promise<O>(async resolve => (
69+
return this.#index = 0,
6670
await this.#nextAsync(...args),
67-
this.onComplete(() => resolve(args as O))
68-
));
71+
this.onComplete(() => args as O),
72+
args as O;
6973
}
7074

7175
/**

0 commit comments

Comments
 (0)