Comparing version 0.4.1 to 0.4.2
@@ -117,15 +117,24 @@ var __defProp = Object.defineProperty; | ||
var traverseRoutes = async (routes, opts) => { | ||
var _a; | ||
let route = routes; | ||
for (const part of opts.path) { | ||
if (route === null || typeof route === "function") | ||
if (typeof route === "function") | ||
return null; | ||
const child = getRouteChild(route, opts, part); | ||
const guardResult = await ((_a = route["?"]) == null ? void 0 : _a.call(route, opts)); | ||
if (guardResult instanceof NavOpts) | ||
return () => guardResult; | ||
if (child === null) | ||
return null; | ||
const gr2 = await checkGuard(route, opts); | ||
if (gr2) | ||
return gr2; | ||
route = child; | ||
} | ||
return route; | ||
if (typeof route === "function") | ||
return route; | ||
const gr = await checkGuard(route, opts); | ||
return gr || route; | ||
}; | ||
var checkGuard = (route, opts) => { | ||
if (!("?" in route)) | ||
return false; | ||
return Promise.resolve(route["?"](opts)).then((gr) => gr instanceof NavOpts && (() => gr)); | ||
}; | ||
var getRouteChild = (route, opts, part) => { | ||
@@ -132,0 +141,0 @@ if (part in route) |
{ | ||
"name": "esroute", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "A small efficient framework-agnostic client-side routing library, written in TypeScript.", | ||
"types": "dist/index.d.ts", | ||
"main": "dist/index.js", | ||
@@ -6,0 +7,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
40333
372