@thi.ng/router 4.0.9 → 4.0.11

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-23T07:02:18Z
3
+ - **Last updated**: 2024-06-21T19:34:38Z
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.
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
9
9
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
10
  and/or version bumps of transitive dependencies.
11
11
 
12
+ ### [4.0.11](https://github.com/thi-ng/umbrella/tree/@thi.ng/router@4.0.11) (2024-06-21)
13
+
14
+ #### ♻️ Refactoring
15
+
16
+ - enforce uniform naming convention of internal functions ([56992b2](https://github.com/thi-ng/umbrella/commit/56992b2))
17
+
12
18
  ### [4.0.8](https://github.com/thi-ng/umbrella/tree/@thi.ng/router@4.0.8) (2024-04-20)
13
19
 
14
20
  #### ♻️ Refactoring
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  [![Mastodon Follow](https://img.shields.io/mastodon/follow/109331703950160316?domain=https%3A%2F%2Fmastodon.thi.ng&style=social)](https://mastodon.thi.ng/@toxi)
8
8
 
9
9
  > [!NOTE]
10
- > This is one of 192 standalone projects, maintained as part
10
+ > This is one of 193 standalone projects, maintained as part
11
11
  > of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
12
12
  > and anti-framework.
13
13
  >
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/router",
3
- "version": "4.0.9",
3
+ "version": "4.0.11",
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",
@@ -10,7 +10,7 @@
10
10
  "type": "git",
11
11
  "url": "https://github.com/thi-ng/umbrella.git"
12
12
  },
13
- "homepage": "https://github.com/thi-ng/umbrella/tree/develop/packages/router#readme",
13
+ "homepage": "https://thi.ng/router",
14
14
  "funding": [
15
15
  {
16
16
  "type": "github",
@@ -36,17 +36,17 @@
36
36
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
37
37
  },
38
38
  "dependencies": {
39
- "@thi.ng/api": "^8.11.1",
40
- "@thi.ng/checks": "^3.6.3",
41
- "@thi.ng/equiv": "^2.1.57",
42
- "@thi.ng/errors": "^2.5.6",
43
- "tslib": "^2.6.2"
39
+ "@thi.ng/api": "^8.11.3",
40
+ "@thi.ng/checks": "^3.6.5",
41
+ "@thi.ng/equiv": "^2.1.59",
42
+ "@thi.ng/errors": "^2.5.8",
43
+ "tslib": "^2.6.3"
44
44
  },
45
45
  "devDependencies": {
46
- "@microsoft/api-extractor": "^7.43.0",
47
- "esbuild": "^0.20.2",
48
- "typedoc": "^0.25.12",
49
- "typescript": "^5.4.3"
46
+ "@microsoft/api-extractor": "^7.47.0",
47
+ "esbuild": "^0.21.5",
48
+ "typedoc": "^0.25.13",
49
+ "typescript": "^5.5.2"
50
50
  },
51
51
  "keywords": [
52
52
  "browser",
@@ -97,5 +97,5 @@
97
97
  ],
98
98
  "year": 2014
99
99
  },
100
- "gitHead": "5dd66c18a3862a3af69a5b2f49563f7cbdd960c2\n"
100
+ "gitHead": "154c95cf9d6bab32174498ec3b5b5d87e42be7f9\n"
101
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";
@@ -132,7 +131,7 @@ let Router = class {
132
131
  if (route) {
133
132
  const params2 = match.params;
134
133
  let parts = route.match.map((x) => {
135
- if (isRouteParam(x)) {
134
+ if (__isRouteParam(x)) {
136
135
  const id2 = x.substring(1);
137
136
  const p = params2?.[id2];
138
137
  if (p == null) {
@@ -162,7 +161,7 @@ let Router = class {
162
161
  }
163
162
  let hasParams = false;
164
163
  const params = match.reduce((acc, x, i) => {
165
- if (isRouteParam(x)) {
164
+ if (__isRouteParam(x)) {
166
165
  hasParams = true;
167
166
  acc[i] = x.substring(1);
168
167
  }
@@ -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(
@@ -229,7 +227,7 @@ let Router = class {
229
227
  Router = __decorateClass([
230
228
  INotifyMixin
231
229
  ], Router);
232
- const isRouteParam = (x) => x[0] === "?";
230
+ const __isRouteParam = (x) => x[0] === "?";
233
231
  export {
234
232
  Router
235
233
  };
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
  }