@uxf/core 11.97.0 → 11.100.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.
- package/README.md +16 -0
- package/package.json +4 -1
- package/utils/ts-pattern.d.ts +1 -0
- package/utils/ts-pattern.js +9 -0
package/README.md
CHANGED
|
@@ -139,6 +139,22 @@ switch(value) {
|
|
|
139
139
|
}
|
|
140
140
|
```
|
|
141
141
|
|
|
142
|
+
### ts-pattern
|
|
143
|
+
|
|
144
|
+
Re-export of the [ts-pattern](https://github.com/gvergnaud/ts-pattern) library for exhaustive pattern matching. This provides a more powerful and type-safe alternative to switch statements with support for complex patterns, guards, and exhaustiveness checking.
|
|
145
|
+
|
|
146
|
+
```ts
|
|
147
|
+
import { match, Pattern } from "@uxf/core/utils/ts-pattern";
|
|
148
|
+
|
|
149
|
+
const result = match(value)
|
|
150
|
+
.with("a", () => "A")
|
|
151
|
+
.with("b", () => "B")
|
|
152
|
+
.with(Pattern.string, (str) => `String: ${str}`)
|
|
153
|
+
.exhaustive();
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
For full documentation, see the [official ts-pattern docs](https://github.com/gvergnaud/ts-pattern).
|
|
157
|
+
|
|
142
158
|
## assertNotNil
|
|
143
159
|
|
|
144
160
|
```tsx
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxf/core",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.100.0",
|
|
4
4
|
"description": "UXF Core",
|
|
5
5
|
"author": "Petr Vejvoda <vejvoda@uxf.cz>",
|
|
6
6
|
"homepage": "https://gitlab.com/uxf-npm/core#readme",
|
|
@@ -19,6 +19,9 @@
|
|
|
19
19
|
"build": "tsc -P tsconfig.json",
|
|
20
20
|
"typecheck": "tsc --noEmit --skipLibCheck"
|
|
21
21
|
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"ts-pattern": "5.9.0"
|
|
24
|
+
},
|
|
22
25
|
"bugs": {
|
|
23
26
|
"url": "https://gitlab.com/uxf-npm/core/issues"
|
|
24
27
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NonExhaustiveError, P, Pattern, isMatching, match } from "ts-pattern";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.match = exports.isMatching = exports.Pattern = exports.P = exports.NonExhaustiveError = void 0;
|
|
4
|
+
var ts_pattern_1 = require("ts-pattern");
|
|
5
|
+
Object.defineProperty(exports, "NonExhaustiveError", { enumerable: true, get: function () { return ts_pattern_1.NonExhaustiveError; } });
|
|
6
|
+
Object.defineProperty(exports, "P", { enumerable: true, get: function () { return ts_pattern_1.P; } });
|
|
7
|
+
Object.defineProperty(exports, "Pattern", { enumerable: true, get: function () { return ts_pattern_1.Pattern; } });
|
|
8
|
+
Object.defineProperty(exports, "isMatching", { enumerable: true, get: function () { return ts_pattern_1.isMatching; } });
|
|
9
|
+
Object.defineProperty(exports, "match", { enumerable: true, get: function () { return ts_pattern_1.match; } });
|