Skip to content

Commit

Permalink
chore: switch for-await-of to Promise.all()
Browse files Browse the repository at this point in the history
  • Loading branch information
younggglcy committed Sep 20, 2022
1 parent ffa84f6 commit 402dce5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/core/useFetch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ function headersToObject(headers: HeadersInit | undefined) {

function chainCallbacks<T = any>(...callbacks: (((ctx: T) => void | Partial<T> | Promise<void | Partial<T>>) | undefined)[]) {
return async (ctx: T) => {
for await (const callback of callbacks) {
await Promise.all(callbacks.map(async (callback) => {
if (callback)
ctx = { ...ctx, ...(callback(ctx)) }
}
ctx = { ...ctx, ...(await callback(ctx)) }
}))
return ctx
}
}
Expand Down

0 comments on commit 402dce5

Please sign in to comment.