@mpen/rerouter 0.1.4 → 0.1.7

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/dist/bundle.cjs CHANGED
@@ -236,7 +236,7 @@ class UriTemplate {
236
236
  if (x.length) {
237
237
  vs.push((v.repeat ? "" : pre) + x.map((z => (v.repeat ? pre : "") + esc(z))).join(v.repeat ? SeparatorMap[p.prefix] : ","));
238
238
  }
239
- } else if (typeof x === "object") {
239
+ } else if (x != null && typeof x === "object") {
240
240
  if (Object.keys(x).length) {
241
241
  vs.push((v.repeat ? "" : pre) + Object.entries(x).map((([ok, ov]) => `${esc(ok)}${v.repeat ? "=" : ","}${esc(ov)}`)).join(v.repeat ? SeparatorMap[p.prefix] : ","));
242
242
  }
package/dist/bundle.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export { UriTemplate } from './uri-template';
2
- export type { UrlParamValue, UriMatch } from './uri-template';
2
+ export type { UrlParamValue, UriMatch, UriParams } from './uri-template';
package/dist/bundle.mjs CHANGED
@@ -234,7 +234,7 @@ class UriTemplate {
234
234
  if (x.length) {
235
235
  vs.push((v.repeat ? "" : pre) + x.map((z => (v.repeat ? pre : "") + esc(z))).join(v.repeat ? SeparatorMap[p.prefix] : ","));
236
236
  }
237
- } else if (typeof x === "object") {
237
+ } else if (x != null && typeof x === "object") {
238
238
  if (Object.keys(x).length) {
239
239
  vs.push((v.repeat ? "" : pre) + Object.entries(x).map((([ok, ov]) => `${esc(ok)}${v.repeat ? "=" : ","}${esc(ov)}`)).join(v.repeat ? SeparatorMap[p.prefix] : ","));
240
240
  }
@@ -32,18 +32,19 @@ type MapItem = {
32
32
  } | {
33
33
  type: VarType.STATIC;
34
34
  };
35
- export declare class UriTemplate {
35
+ export declare class UriTemplate<P extends UriParams> {
36
36
  expandParts: TemplateParts;
37
37
  matchRegex: RegExp;
38
38
  matchMap: Map<string, MapItem>;
39
39
  constructor(template: string);
40
- expand(variables: Record<string, UrlParamValue>): string;
41
- match(url: string): UriMatch | null;
40
+ expand(variables: P): string;
41
+ match(url: string): UriMatch<P> | null;
42
42
  }
43
- export type UrlParamValue = string | number | string[] | number[] | Record<string, string | number | null>;
44
- export type UriParams = Record<string, UrlParamValue | null>;
45
- export type UriMatch = {
43
+ export type UrlParamValue = string | number | boolean | string[] | number[] | Record<string, string | number | boolean | null>;
44
+ type NullableUrlParamValue = UrlParamValue | null;
45
+ export type UriParams = Record<string, NullableUrlParamValue>;
46
+ export type UriMatch<P extends UriParams> = {
46
47
  score: number;
47
- params: UriParams;
48
+ params: P;
48
49
  };
49
50
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpen/rerouter",
3
- "version": "0.1.4",
3
+ "version": "0.1.7",
4
4
  "packageManager": "bun",
5
5
  "exports": "./dist/bundle.cjs",
6
6
  "module": "./dist/bundle.mjs",