@mkvlrn/result 5.0.1 → 5.0.2
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 +12 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Type-safe Result pattern for TypeScript representing success or error. Anything to avoid try/catch hell.
|
|
4
4
|
|
|
5
|
+
[](https://www.npmjs.com/package/@mkvlrn/result)
|
|
6
|
+
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
7
9
|
```bash
|
|
@@ -28,6 +30,15 @@ if (result.isError) {
|
|
|
28
30
|
}
|
|
29
31
|
```
|
|
30
32
|
|
|
33
|
+
## API
|
|
34
|
+
|
|
35
|
+
| Export | Description |
|
|
36
|
+
| ------------------- | -------------------------------------------- |
|
|
37
|
+
| `Result<T, E>` | Union type representing success or failure |
|
|
38
|
+
| `AsyncResult<T, E>` | `Promise<Result<T, E>>` for async operations |
|
|
39
|
+
| `ok(value)` | Creates a success result |
|
|
40
|
+
| `err(error)` | Creates an error result |
|
|
41
|
+
|
|
31
42
|
## Examples
|
|
32
43
|
|
|
33
44
|
### Basic Function
|
|
@@ -41,7 +52,7 @@ function divide(a: number, b: number): Result<number, Error> {
|
|
|
41
52
|
}
|
|
42
53
|
|
|
43
54
|
const result = divide(10, 2);
|
|
44
|
-
if (
|
|
55
|
+
if (result.isOk) {
|
|
45
56
|
console.log(result.value); // 5
|
|
46
57
|
}
|
|
47
58
|
```
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mkvlrn/result",
|
|
3
3
|
"description": "Simple Result type/pattern for TypeScript",
|
|
4
|
-
"version": "5.0.
|
|
4
|
+
"version": "5.0.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"author": "Mike Valeriano <mkvlrn@proton.me>",
|
|
@@ -25,17 +25,17 @@
|
|
|
25
25
|
"default": "./build/index.js"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@types/node": "^
|
|
29
|
-
"lint-staged": "^16.2.
|
|
30
|
-
"rimraf": "^6.1.
|
|
28
|
+
"@types/node": "^25.0.3",
|
|
29
|
+
"lint-staged": "^16.2.7",
|
|
30
|
+
"rimraf": "^6.1.2",
|
|
31
31
|
"tsc-files": "^1.1.4",
|
|
32
|
-
"tsdown": "^0.
|
|
33
|
-
"tsx": "^4.
|
|
32
|
+
"tsdown": "^0.18.2",
|
|
33
|
+
"tsx": "^4.21.0",
|
|
34
34
|
"typescript": "^5.9.3",
|
|
35
|
-
"vite-tsconfig-paths": "^
|
|
35
|
+
"vite-tsconfig-paths": "^6.0.3"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"vitest": "^4.0.
|
|
38
|
+
"vitest": "^4.0.16"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "tsdown",
|