Niedzielski has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/380674 )
Change subject: Chore: restructure Router.ParsedRoute construction ...................................................................... Chore: restructure Router.ParsedRoute construction Focus on the unit instead of the whole by refactoring parseRoutes() to parseRoute(). Change-Id: I0f42bb1fd47bdda2a8e87047a2d35224802d5b2b --- M src/common/routers/router.ts 1 file changed, 9 insertions(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/marvin refs/changes/74/380674/1 diff --git a/src/common/routers/router.ts b/src/common/routers/router.ts index 308e1de..5d07135 100644 --- a/src/common/routers/router.ts +++ b/src/common/routers/router.ts @@ -18,15 +18,14 @@ regularExpression: RegExp; } -const parseRoutes = (routes: AnyRoute[]) => - routes.map((route: AnyRoute): ParsedRoute => { - const paramNames: pathToRegExp.Key[] = []; - return { - ...route, - paramNames, - regularExpression: pathToRegExp(route.path, paramNames) - }; - }); +const parseRoute = (route: AnyRoute): ParsedRoute => { + const paramNames: pathToRegExp.Key[] = []; + return { + ...route, + paramNames, + regularExpression: pathToRegExp(route.path, paramNames) + }; +}; // This method is tightly coupled with Route.path and the parameters supplied to // PageModule.requestProps. Route.path must use names that match the typing for @@ -69,7 +68,7 @@ } export const newRouter = (routes: AnyRoute[]): Router => { - const parsedRoutes: ParsedRoute[] = parseRoutes(routes); + const parsedRoutes: ParsedRoute[] = routes.map(route => parseRoute(route)); return { route(url) { -- To view, visit https://gerrit.wikimedia.org/r/380674 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0f42bb1fd47bdda2a8e87047a2d35224802d5b2b Gerrit-PatchSet: 1 Gerrit-Project: marvin Gerrit-Branch: master Gerrit-Owner: Niedzielski <sniedziel...@wikimedia.org> Gerrit-Reviewer: Sniedzielski <sniedziel...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits