( pattern: string, route: MaybeLazy<Route<State>>, config: RouteConfig | undefined, includeLastSegment: boolean, )
| 140 | includeLastSegment: boolean; |
| 141 | } |
| 142 | export function newRouteCmd<State>( |
| 143 | pattern: string, |
| 144 | route: MaybeLazy<Route<State>>, |
| 145 | config: RouteConfig | undefined, |
| 146 | includeLastSegment: boolean, |
| 147 | ): RouteCommand<State> { |
| 148 | let normalized; |
| 149 | if (isLazy(route)) { |
| 150 | normalized = async () => { |
| 151 | const result = await route(); |
| 152 | ensureHandler(result); |
| 153 | return result; |
| 154 | }; |
| 155 | } else { |
| 156 | ensureHandler(route); |
| 157 | normalized = route; |
| 158 | } |
| 159 | |
| 160 | return { |
| 161 | type: CommandType.Route, |
| 162 | pattern, |
| 163 | route: normalized, |
| 164 | config, |
| 165 | includeLastSegment, |
| 166 | }; |
| 167 | } |
| 168 | |
| 169 | export interface HandlerCommand<State> { |
| 170 | type: CommandType.Handler; |
no test coverage detected