@shakerquiz/utilities 4.0.2 → 4.0.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,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@shakerquiz/utilities",
4
- "version": "4.0.2",
4
+ "version": "4.0.3",
5
5
  "author": "yurkimus <yurkimus@gmail.com>",
6
6
  "license": "ISC",
7
7
  "repository": {
@@ -1,4 +1,4 @@
1
- import { ParameterPattern, PathnameParameters, Route, RoutePathname } from '../codegen/autogenerated.js'
1
+ import { PathnameParameters, Route, RoutePathname } from '../codegen/autogenerated.js'
2
2
  import { access } from './access.js'
3
3
 
4
4
  /**
@@ -24,27 +24,3 @@ export const hydrateRoutePathname = (maybeRoute, maybeParams) => {
24
24
  ? pathname.replace(parameter, maybeParams[index])
25
25
  : pathname, pathname)
26
26
  }
27
-
28
- /**
29
- * @template {keyof typeof import('@shakerquiz/utilities').Route} R
30
- *
31
- * @param {R} maybeRoute
32
- * @param {any[]} maybeParams
33
- *
34
- * @returns {typeof import('@shakerquiz/utilities').RoutePathname[R]}
35
- */
36
- export const parametrizeRoutePathname = (maybeRoute, maybeParams) => {
37
- if (!Array.isArray(maybeParams))
38
- throw TypeError(`Parameter 'params' must be 'Array'.`)
39
-
40
- var route = access(Route, maybeRoute)
41
-
42
- var pathname = access(RoutePathname, route)
43
-
44
- var pathnameParameters = access(PathnameParameters, pathname)
45
-
46
- return pathnameParameters.reduce((pathname, parameter, index) =>
47
- Object.hasOwn(maybeParams, index)
48
- ? pathname.replace(parameter, maybeParams[index])
49
- : pathname.replace(parameter, access(ParameterPattern, parameter)), pathname)
50
- }
@@ -1,7 +1,7 @@
1
1
  import { Method } from '../entities/method.js'
2
2
 
3
3
  import { access } from './access.js'
4
- import { hydrateRoutePathname, parametrizeRoutePathname } from './route-pathname.js'
4
+ import { hydrateRoutePathname } from './route-pathname.js'
5
5
 
6
6
  /**
7
7
  * @template {keyof typeof import('@shakerquiz/utilities').Method} M
@@ -26,29 +26,6 @@ export const tag = (maybeMethod, maybeRoute, maybeParams) => {
26
26
  return method + '/' + hydrateRoutePathname(maybeRoute, maybeParams)
27
27
  }
28
28
 
29
- /**
30
- * @template {keyof typeof import('@shakerquiz/utilities').Method} M
31
- * @template {keyof typeof import('@shakerquiz/utilities').Route} R
32
- *
33
- * @param {M} maybeMethod
34
- * @param {R} maybeRoute
35
- * @param {any[]} maybeParams
36
- *
37
- * @returns {`${M}/${ReturnType<typeof parametrizeRoutePathname<R>>}`}
38
- *
39
- * @example
40
- * tagplate('GET', 'cities', []) // => 'GET/cities'
41
- *
42
- * tagplate('GET', 'game/theme/cover', ['<g>']) // => 'GET/game/<g>/theme/<related pattern>/<related pattern>'
43
- *
44
- * tagplate('POST', 'city', []) // => 'POST/city/<related pattern>'
45
- */
46
- export const tagplate = (maybeMethod, maybeRoute, maybeParams) => {
47
- var method = access(Method, maybeMethod)
48
-
49
- return method + '/' + parametrizeRoutePathname(maybeRoute, maybeParams)
50
- }
51
-
52
29
  /**
53
30
  * @template {keyof typeof import('@shakerquiz/utilities').Method} M
54
31
  * @template {keyof typeof import('@shakerquiz/utilities').Route} R
@@ -58,4 +35,4 @@ export const tagplate = (maybeMethod, maybeRoute, maybeParams) => {
58
35
  * @param {any[]} maybeParams
59
36
  */
60
37
  export const tagexp = (maybeMethod, maybeRoute, maybeParams) =>
61
- new RegExp(`^${tagplate(maybeMethod, maybeRoute, maybeParams)}$`)
38
+ new RegExp(`^${tag(maybeMethod, maybeRoute, maybeParams)}$`)