mqtt-pattern 2.0.1 → 2.1.1
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/index.d.ts +2 -0
- package/package.json +1 -1
- package/parameters.d.ts +4 -4
- package/test.ts +2 -1
package/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { MqttParameters, FillTopic, CleanTopic } from "./parameters";
|
|
2
2
|
import type { F } from "ts-toolbelt";
|
|
3
3
|
|
|
4
|
+
export type { MqttParameters } from './parameters'
|
|
5
|
+
|
|
4
6
|
/**
|
|
5
7
|
* Extract parameters from a topic based on the pattern provided
|
|
6
8
|
* @param pattern Pattern to match against
|
package/package.json
CHANGED
package/parameters.d.ts
CHANGED
|
@@ -65,14 +65,14 @@ type FillParam<
|
|
|
65
65
|
? PName extends keyof Parameters
|
|
66
66
|
? Parameters[PName] extends string
|
|
67
67
|
? Parameters[PName]
|
|
68
|
-
:
|
|
69
|
-
:
|
|
68
|
+
: never
|
|
69
|
+
: never
|
|
70
70
|
: Section extends `#${infer PName}`
|
|
71
71
|
? PName extends keyof Parameters
|
|
72
72
|
? Parameters[PName] extends string[]
|
|
73
73
|
? JoinPath<Parameters[PName]>
|
|
74
|
-
:
|
|
75
|
-
:
|
|
74
|
+
: never
|
|
75
|
+
: never
|
|
76
76
|
: Section;
|
|
77
77
|
|
|
78
78
|
export type FillTopic<
|
package/test.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { clean, exec, extract, fill, matches } from "./index";
|
|
1
|
+
import { clean, exec, extract, fill, matches, MqttParameters } from "./index";
|
|
2
2
|
import { Test } from "ts-toolbelt";
|
|
3
3
|
import test from "node:test";
|
|
4
4
|
// Type Testing
|
|
@@ -9,6 +9,7 @@ const { check, checks } = Test;
|
|
|
9
9
|
const execv = exec("foo/bar/+baz", "foo/bar/test");
|
|
10
10
|
checks([
|
|
11
11
|
check<typeof execv, { baz: string } | null, Test.Pass>(),
|
|
12
|
+
check<typeof execv, MqttParameters<"foo/bar/+baz"> | null, Test.Pass>(),
|
|
12
13
|
check<typeof execv, { baz: string[] } | null, Test.Fail>(),
|
|
13
14
|
]);
|
|
14
15
|
|