@thi.ng/router 4.0.8 → 4.0.10

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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2024-04-20T14:42:45Z
3
+ - **Last updated**: 2024-05-08T18:24:32Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/router",
3
- "version": "4.0.8",
3
+ "version": "4.0.10",
4
4
  "description": "Generic trie-based router with support for wildcards, route param validation/coercion, auth",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -27,7 +27,7 @@
27
27
  "build": "yarn build:esbuild && yarn build:decl",
28
28
  "build:decl": "tsc --declaration --emitDeclarationOnly",
29
29
  "build:esbuild": "esbuild --format=esm --platform=neutral --target=es2022 --tsconfig=tsconfig.json --outdir=. src/**/*.ts",
30
- "clean": "rimraf --glob '*.js' '*.d.ts' '*.map' doc",
30
+ "clean": "bun ../../tools/src/clean-package.ts",
31
31
  "doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
32
32
  "doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
33
33
  "doc:readme": "bun ../../tools/src/module-stats.ts && bun ../../tools/src/readme.ts",
@@ -36,18 +36,17 @@
36
36
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
37
37
  },
38
38
  "dependencies": {
39
- "@thi.ng/api": "^8.11.0",
40
- "@thi.ng/checks": "^3.6.2",
41
- "@thi.ng/equiv": "^2.1.56",
42
- "@thi.ng/errors": "^2.5.5",
39
+ "@thi.ng/api": "^8.11.2",
40
+ "@thi.ng/checks": "^3.6.4",
41
+ "@thi.ng/equiv": "^2.1.58",
42
+ "@thi.ng/errors": "^2.5.7",
43
43
  "tslib": "^2.6.2"
44
44
  },
45
45
  "devDependencies": {
46
- "@microsoft/api-extractor": "^7.43.0",
47
- "esbuild": "^0.20.2",
48
- "rimraf": "^5.0.5",
49
- "typedoc": "^0.25.12",
50
- "typescript": "^5.4.3"
46
+ "@microsoft/api-extractor": "^7.43.2",
47
+ "esbuild": "^0.21.1",
48
+ "typedoc": "^0.25.13",
49
+ "typescript": "^5.4.5"
51
50
  },
52
51
  "keywords": [
53
52
  "browser",
@@ -98,5 +97,5 @@
98
97
  ],
99
98
  "year": 2014
100
99
  },
101
- "gitHead": "8339d05ecc857e529c7325a9839c0063b89e728d\n"
100
+ "gitHead": "df34b4a9e650cc7323575356de207d78933bdcf3\n"
102
101
  }
package/router.js CHANGED
@@ -5,8 +5,7 @@ var __decorateClass = (decorators, target, key, kind) => {
5
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
6
  if (decorator = decorators[i])
7
7
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result)
9
- __defProp(target, key, result);
8
+ if (kind && result) __defProp(target, key, result);
10
9
  return result;
11
10
  };
12
11
  import { INotifyMixin } from "@thi.ng/api/mixins/inotify";
@@ -179,8 +178,7 @@ let Router = class {
179
178
  matchRoutes(src, ctx) {
180
179
  const curr = src.split(this.opts.separator);
181
180
  const route = this.routes.get(curr);
182
- if (!route)
183
- return;
181
+ if (!route) return;
184
182
  let params;
185
183
  if (route.params) {
186
184
  params = Object.entries(route.params).reduce(
package/trie.js CHANGED
@@ -4,10 +4,8 @@ class Trie {
4
4
  v;
5
5
  constructor(key, v, i = 0) {
6
6
  if (key && v !== void 0) {
7
- if (i < key.length)
8
- this.set(key, v, i);
9
- else
10
- this.v = v;
7
+ if (i < key.length) this.set(key, v, i);
8
+ else this.v = v;
11
9
  }
12
10
  }
13
11
  set(key, v, i = 0) {
@@ -18,25 +16,18 @@ class Trie {
18
16
  let k = key[i];
19
17
  if (k === "+" && i < key.length - 1)
20
18
  illegalArgs("`+` only allowed in tail position");
21
- if (k[0] === "?")
22
- k = "?";
19
+ if (k[0] === "?") k = "?";
23
20
  const next = this.n[k];
24
- if (next)
25
- next.set(key, v, i + 1);
26
- else
27
- this.n[k] = new Trie(key, v, i + 1);
21
+ if (next) next.set(key, v, i + 1);
22
+ else this.n[k] = new Trie(key, v, i + 1);
28
23
  }
29
24
  get(key, i = 0) {
30
- if (i >= key.length)
31
- return this.v;
25
+ if (i >= key.length) return this.v;
32
26
  let value;
33
27
  let next;
34
- if (next = this.n[key[i]])
35
- value = next.get(key, i + 1);
36
- if (value !== void 0)
37
- return value;
38
- if (next = this.n["?"])
39
- value = next.get(key, i + 1);
28
+ if (next = this.n[key[i]]) value = next.get(key, i + 1);
29
+ if (value !== void 0) return value;
30
+ if (next = this.n["?"]) value = next.get(key, i + 1);
40
31
  return value !== void 0 ? value : this.n["+"]?.v;
41
32
  }
42
33
  }