@shakerquiz/utilities 0.6.1 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { RoutePathnameParams } from '../entities/route-pathname-params.js'
|
|
2
|
+
import { RoutePathname } from '../entities/route-pathname.js'
|
|
3
|
+
import { Route } from '../entities/route.js'
|
|
4
|
+
import { Relation } from '../prototypes/relation.js'
|
|
3
5
|
|
|
4
6
|
export const hydrateRoutePathname = Object.freeze(
|
|
5
7
|
/**
|
|
@@ -12,21 +14,18 @@ export const hydrateRoutePathname = Object.freeze(
|
|
|
12
14
|
if (!Array.isArray(params))
|
|
13
15
|
throw TypeError(`Parameter 'params' must be 'Array'.`)
|
|
14
16
|
|
|
15
|
-
var
|
|
17
|
+
var r = Relation
|
|
18
|
+
.of(Route)
|
|
19
|
+
.require(route)
|
|
16
20
|
|
|
17
|
-
var
|
|
21
|
+
var rp = Relation
|
|
22
|
+
.of(RoutePathname)
|
|
23
|
+
.require(r)
|
|
18
24
|
|
|
19
|
-
|
|
20
|
-
|
|
25
|
+
var rpp = Relation
|
|
26
|
+
.of(RoutePathnameParams)
|
|
27
|
+
.require(r)
|
|
21
28
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (rpm === 'Unknown')
|
|
25
|
-
throw TypeError(`Could not infer route params of: '${$route}'.`)
|
|
26
|
-
|
|
27
|
-
return rpm.reduce(
|
|
28
|
-
(pathname, param, index) => pathname.replace(param, params[index]),
|
|
29
|
-
$routePathname,
|
|
30
|
-
)
|
|
29
|
+
return rpp.reduce((rp, rpp, i) => rp.replace(rpp, params[i]), rp)
|
|
31
30
|
},
|
|
32
31
|
)
|
package/source/helpers/tag.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Method } from '../entities/method.js'
|
|
2
|
+
import { Relation } from '../prototypes/relation.js'
|
|
3
3
|
import { hydrateRoutePathname } from './hydrate-route-pathname.js'
|
|
4
4
|
|
|
5
5
|
export const tag = Object.freeze(
|
|
@@ -15,10 +15,9 @@ export const tag = Object.freeze(
|
|
|
15
15
|
* @returns {`${MethodTemplate}/${RoutePathnameTemplate}`}
|
|
16
16
|
*/
|
|
17
17
|
(method, route, params) => {
|
|
18
|
-
var m =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
throw TypeError(`Could not infer method of: '${method}'.`)
|
|
18
|
+
var m = Relation
|
|
19
|
+
.of(Method)
|
|
20
|
+
.require(method)
|
|
22
21
|
|
|
23
22
|
return m + '/' + hydrateRoutePathname(route, params)
|
|
24
23
|
},
|
package/source/index.js
CHANGED
|
File without changes
|