Skip to content

Commit 30ddc26

Browse files
authored
simplify AsyncHooks#_prepareHook
1 parent eee488c commit 30ddc26

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

Diff for: src/util.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,9 @@ export class AsyncHooks {
8787

8888
_prepareHook(chain: Hook[]) {
8989
return async function hook(...args: any[]): Promise<any> {
90-
return await next(0);
91-
92-
async function next(i: number, result?: any): Promise<any> {
93-
const fn = chain[i];
94-
if (result !== undefined || fn === undefined) return result;
95-
return await new Promise(resolve => resolve(fn(...args))).then(next.bind(null, i + 1));
90+
for (const fn of chain) {
91+
const result = await Promise.resolve(fn(...args));
92+
if (result !== undefined) return result;
9693
}
9794
};
9895
}

0 commit comments

Comments
 (0)