@uxf/router 11.32.0 → 11.42.0

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.
Files changed (3) hide show
  1. package/helper.d.ts +1 -0
  2. package/helper.js +8 -0
  3. package/package.json +34 -34
package/helper.d.ts CHANGED
@@ -5,4 +5,5 @@ export declare function queryParamToBoolean(param: ParamType): boolean | undefin
5
5
  export declare function queryParamToBooleanStrict(param: ParamType): boolean;
6
6
  export declare function queryParamToNumber(param: ParamType): number | undefined;
7
7
  export declare function queryParamToNumberStrict(param: ParamType): number;
8
+ export declare function queryParamToEnumStrict<T>(param: ParamType, enums: Record<string, any>, fallback: T): T;
8
9
  export {};
package/helper.js CHANGED
@@ -6,6 +6,7 @@ exports.queryParamToBoolean = queryParamToBoolean;
6
6
  exports.queryParamToBooleanStrict = queryParamToBooleanStrict;
7
7
  exports.queryParamToNumber = queryParamToNumber;
8
8
  exports.queryParamToNumberStrict = queryParamToNumberStrict;
9
+ exports.queryParamToEnumStrict = queryParamToEnumStrict;
9
10
  function queryParamToString(param) {
10
11
  if (Array.isArray(param)) {
11
12
  throw new Error(`Query parameter is array. Should be string.`);
@@ -61,3 +62,10 @@ function queryParamToNumberStrict(param) {
61
62
  }
62
63
  return paramOrUndefined;
63
64
  }
65
+ function queryParamToEnumStrict(param, enums, fallback) {
66
+ const result = queryParamToString(Array.isArray(param) ? param.at(0) : param);
67
+ if (result && Object.values(enums).includes(result)) {
68
+ return result;
69
+ }
70
+ return fallback;
71
+ }
package/package.json CHANGED
@@ -1,35 +1,35 @@
1
1
  {
2
- "name": "@uxf/router",
3
- "version": "11.32.0",
4
- "description": "UXF Router",
5
- "author": "UXFans <dev@uxf.cz>",
6
- "homepage": "https://gitlab.com/uxf-npm/router#readme",
7
- "license": "ISC",
8
- "main": "index.js",
9
- "typings": "index.d.ts",
10
- "module": "index.js",
11
- "publishConfig": {
12
- "access": "public"
13
- },
14
- "repository": {
15
- "type": "git",
16
- "url": "git+https://gitlab.com/uxf-npm/router.git"
17
- },
18
- "scripts": {
19
- "build": "tsc -P tsconfig.json",
20
- "typecheck": "tsc --noEmit --skipLibCheck"
21
- },
22
- "bugs": {
23
- "url": "https://gitlab.com/uxf-npm/router/issues"
24
- },
25
- "dependencies": {
26
- "qs": "6.13.0"
27
- },
28
- "peerDependencies": {
29
- "next": ">= 12"
30
- },
31
- "devDependencies": {
32
- "@types/qs": "6.9.15",
33
- "next": "14.2.6"
34
- }
35
- }
2
+ "name": "@uxf/router",
3
+ "version": "11.42.0",
4
+ "description": "UXF Router",
5
+ "author": "UXFans <dev@uxf.cz>",
6
+ "homepage": "https://gitlab.com/uxf-npm/router#readme",
7
+ "license": "ISC",
8
+ "main": "index.js",
9
+ "typings": "index.d.ts",
10
+ "module": "index.js",
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://gitlab.com/uxf-npm/router.git"
17
+ },
18
+ "scripts": {
19
+ "build": "tsc -P tsconfig.json",
20
+ "typecheck": "tsc --noEmit --skipLibCheck"
21
+ },
22
+ "bugs": {
23
+ "url": "https://gitlab.com/uxf-npm/router/issues"
24
+ },
25
+ "dependencies": {
26
+ "qs": "6.13.0"
27
+ },
28
+ "peerDependencies": {
29
+ "next": ">= 12"
30
+ },
31
+ "devDependencies": {
32
+ "@types/qs": "6.9.15",
33
+ "next": "14.2.6"
34
+ }
35
+ }