mirror of
https://github.com/honojs/hono.git
synced 2024-12-01 11:51:01 +01:00
refactor(compose): cache length (#460)
This commit is contained in:
parent
6d306b8218
commit
0370cac372
@ -7,6 +7,7 @@ export const compose = <C>(
|
||||
onError?: ErrorHandler,
|
||||
onNotFound?: NotFoundHandler
|
||||
) => {
|
||||
const middlewareLength = middleware.length
|
||||
return (context: C, next?: Function) => {
|
||||
let index = -1
|
||||
return dispatch(0)
|
||||
@ -16,7 +17,7 @@ export const compose = <C>(
|
||||
}
|
||||
let handler = middleware[i]
|
||||
index = i
|
||||
if (i === middleware.length && next) handler = next
|
||||
if (i === middlewareLength && next) handler = next
|
||||
|
||||
if (!handler) {
|
||||
if (context instanceof HonoContext && context.finalized === false && onNotFound) {
|
||||
|
Loading…
Reference in New Issue
Block a user