@shakerquiz/utilities 0.6.1 → 0.6.2

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,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@shakerquiz/utilities",
4
- "version": "0.6.1",
4
+ "version": "0.6.2",
5
5
  "author": "yurkimus <yurkimus@gmail.com>",
6
6
  "license": "ISC",
7
7
  "repository": {
@@ -1,5 +1,7 @@
1
- import { checkRoute } from '../application/route.js'
2
- import { inferRouteParams, inferRoutePathname } from '../system/route.js'
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 $route = checkRoute(route)
17
+ var r = Relation
18
+ .of(Route)
19
+ .require(route)
16
20
 
17
- var $routePathname = inferRoutePathname($route)
21
+ var rp = Relation
22
+ .of(RoutePathname)
23
+ .require(r)
18
24
 
19
- if ($routePathname === 'Unknown')
20
- throw TypeError(`Could not infer route pathname of: '${$route}'.`)
25
+ var rpp = Relation
26
+ .of(RoutePathnameParams)
27
+ .require(r)
21
28
 
22
- var rpm = inferRouteParams($route)
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
  )
@@ -1,5 +1,5 @@
1
- import { inferMethod } from '../system/method.js'
2
-
1
+ import { Method } from '../entities/mode.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 = inferMethod(method)
19
-
20
- if (m === 'Unknown')
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
@@ -38,4 +38,4 @@ export * from './entities/venue-status.js'
38
38
  export * from './helpers/hydrate-route-pathname.js'
39
39
  export * from './helpers/string-tag.js'
40
40
  export * from './helpers/tag.js'
41
- export * from './prototypes/reflection.js'
41
+ export * from './prototypes/relation.js'