happy-rusty 1.1.0 → 1.1.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.cn.md +1 -1
- package/README.md +1 -1
- package/dist/main.cjs +12 -0
- package/dist/main.cjs.map +1 -1
- package/dist/main.mjs +12 -0
- package/dist/main.mjs.map +1 -1
- package/dist/types.d.ts +19 -2
- package/docs/{index.md → README.md} +4 -4
- package/docs/functions/Err.md +8 -8
- package/docs/functions/Ok.md +8 -8
- package/docs/functions/Some.md +8 -8
- package/docs/functions/promiseToResult.md +8 -8
- package/docs/interfaces/None.md +127 -127
- package/docs/interfaces/Option.md +113 -119
- package/docs/interfaces/Result.md +161 -110
- package/docs/type-aliases/AsyncIOResult.md +8 -8
- package/docs/type-aliases/AsyncOption.md +8 -8
- package/docs/type-aliases/AsyncResult.md +8 -8
- package/docs/type-aliases/IOResult.md +8 -8
- package/docs/variables/None.md +4 -4
- package/package.json +8 -8
- package/src/enum/prelude.ts +35 -2
package/docs/functions/Err.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
[**happy-rusty**](../
|
|
1
|
+
[**happy-rusty**](../README.md) • **Docs**
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
5
|
-
[happy-rusty](../
|
|
5
|
+
[happy-rusty](../README.md) / Err
|
|
6
6
|
|
|
7
7
|
# Function: Err()
|
|
8
8
|
|
|
@@ -13,17 +13,17 @@ function Err<T, E>(error): Result<T, E>
|
|
|
13
13
|
Creates a `Result<T, E>` representing a failed outcome containing an error.
|
|
14
14
|
This function is used to construct a `Result` that signifies the operation failed by containing the error `E`.
|
|
15
15
|
|
|
16
|
-
## Type
|
|
16
|
+
## Type Parameters
|
|
17
17
|
|
|
18
|
-
| Type
|
|
19
|
-
|
|
|
18
|
+
| Type Parameter | Description |
|
|
19
|
+
| ------ | ------ |
|
|
20
20
|
| `T` | The type of the value that the result could potentially contain (not used in this case). |
|
|
21
21
|
| `E` | The type of the error to be wrapped in the `Err` result. |
|
|
22
22
|
|
|
23
23
|
## Parameters
|
|
24
24
|
|
|
25
25
|
| Parameter | Type | Description |
|
|
26
|
-
|
|
|
26
|
+
| ------ | ------ | ------ |
|
|
27
27
|
| `error` | `E` | The error to wrap as an `Err` result. |
|
|
28
28
|
|
|
29
29
|
## Returns
|
|
@@ -41,6 +41,6 @@ if (badResult.isErr()) {
|
|
|
41
41
|
}
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
##
|
|
44
|
+
## Defined in
|
|
45
45
|
|
|
46
|
-
[
|
|
46
|
+
[prelude.ts:881](https://github.com/JiangJie/happy-rusty/blob/7218a182717eb5dbba4bfaf783977bc5e378815a/src/enum/prelude.ts#L881)
|
package/docs/functions/Ok.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
[**happy-rusty**](../
|
|
1
|
+
[**happy-rusty**](../README.md) • **Docs**
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
5
|
-
[happy-rusty](../
|
|
5
|
+
[happy-rusty](../README.md) / Ok
|
|
6
6
|
|
|
7
7
|
# Function: Ok()
|
|
8
8
|
|
|
@@ -13,17 +13,17 @@ function Ok<T, E>(value): Result<T, E>
|
|
|
13
13
|
Creates a `Result<T, E>` representing a successful outcome containing a value.
|
|
14
14
|
This function is used to construct a `Result` that signifies the operation was successful by containing the value `T`.
|
|
15
15
|
|
|
16
|
-
## Type
|
|
16
|
+
## Type Parameters
|
|
17
17
|
|
|
18
|
-
| Type
|
|
19
|
-
|
|
|
18
|
+
| Type Parameter | Description |
|
|
19
|
+
| ------ | ------ |
|
|
20
20
|
| `T` | The type of the value to be contained in the `Ok` result. |
|
|
21
21
|
| `E` | The type of the error that the result could potentially contain (not used in this case). |
|
|
22
22
|
|
|
23
23
|
## Parameters
|
|
24
24
|
|
|
25
25
|
| Parameter | Type | Description |
|
|
26
|
-
|
|
|
26
|
+
| ------ | ------ | ------ |
|
|
27
27
|
| `value` | `T` | The value to wrap as an `Ok` result. |
|
|
28
28
|
|
|
29
29
|
## Returns
|
|
@@ -41,6 +41,6 @@ if (goodResult.isOk()) {
|
|
|
41
41
|
}
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
##
|
|
44
|
+
## Defined in
|
|
45
45
|
|
|
46
|
-
[
|
|
46
|
+
[prelude.ts:795](https://github.com/JiangJie/happy-rusty/blob/7218a182717eb5dbba4bfaf783977bc5e378815a/src/enum/prelude.ts#L795)
|
package/docs/functions/Some.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
[**happy-rusty**](../
|
|
1
|
+
[**happy-rusty**](../README.md) • **Docs**
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
5
|
-
[happy-rusty](../
|
|
5
|
+
[happy-rusty](../README.md) / Some
|
|
6
6
|
|
|
7
7
|
# Function: Some()
|
|
8
8
|
|
|
@@ -13,16 +13,16 @@ function Some<T>(value): Option<T>
|
|
|
13
13
|
Creates an `Option<T>` representing the presence of a value.
|
|
14
14
|
This function is typically used to construct an `Option` that contains a value, indicating that the operation yielding the value was successful.
|
|
15
15
|
|
|
16
|
-
## Type
|
|
16
|
+
## Type Parameters
|
|
17
17
|
|
|
18
|
-
| Type
|
|
19
|
-
|
|
|
18
|
+
| Type Parameter | Description |
|
|
19
|
+
| ------ | ------ |
|
|
20
20
|
| `T` | The type of the value to be wrapped in a `Some`. |
|
|
21
21
|
|
|
22
22
|
## Parameters
|
|
23
23
|
|
|
24
24
|
| Parameter | Type | Description |
|
|
25
|
-
|
|
|
25
|
+
| ------ | ------ | ------ |
|
|
26
26
|
| `value` | `T` | The value to wrap as a `Some` option. |
|
|
27
27
|
|
|
28
28
|
## Returns
|
|
@@ -40,6 +40,6 @@ if (maybeValue.isSome()) {
|
|
|
40
40
|
}
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
##
|
|
43
|
+
## Defined in
|
|
44
44
|
|
|
45
|
-
[
|
|
45
|
+
[prelude.ts:646](https://github.com/JiangJie/happy-rusty/blob/7218a182717eb5dbba4bfaf783977bc5e378815a/src/enum/prelude.ts#L646)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
[**happy-rusty**](../
|
|
1
|
+
[**happy-rusty**](../README.md) • **Docs**
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
5
|
-
[happy-rusty](../
|
|
5
|
+
[happy-rusty](../README.md) / promiseToResult
|
|
6
6
|
|
|
7
7
|
# Function: promiseToResult()
|
|
8
8
|
|
|
@@ -13,17 +13,17 @@ function promiseToResult<T, E>(p): Promise<Result<T, E>>
|
|
|
13
13
|
Converts a Promise to a Result type, capturing the resolved value in an `Ok`, or the error in an `Err`.
|
|
14
14
|
This allows for promise-based asynchronous operations to be handled in a way that is more in line with the Result pattern.
|
|
15
15
|
|
|
16
|
-
## Type
|
|
16
|
+
## Type Parameters
|
|
17
17
|
|
|
18
|
-
| Type
|
|
19
|
-
|
|
|
18
|
+
| Type Parameter | Default type | Description |
|
|
19
|
+
| ------ | ------ | ------ |
|
|
20
20
|
| `T` | - | The type of the value that the promise resolves to. |
|
|
21
21
|
| `E` | `Error` | The type of the error that the promise may reject with, defaults to `Error`. |
|
|
22
22
|
|
|
23
23
|
## Parameters
|
|
24
24
|
|
|
25
25
|
| Parameter | Type | Description |
|
|
26
|
-
|
|
|
26
|
+
| ------ | ------ | ------ |
|
|
27
27
|
| `p` | `Promise`\<`T`\> | The promise to convert into a `Result` type. |
|
|
28
28
|
|
|
29
29
|
## Returns
|
|
@@ -45,6 +45,6 @@ async function example() {
|
|
|
45
45
|
}
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
##
|
|
48
|
+
## Defined in
|
|
49
49
|
|
|
50
|
-
[
|
|
50
|
+
[prelude.ts:992](https://github.com/JiangJie/happy-rusty/blob/7218a182717eb5dbba4bfaf783977bc5e378815a/src/enum/prelude.ts#L992)
|