happy-rusty 1.4.0 → 1.6.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/CHANGELOG.md +206 -0
- package/README.cn.md +253 -26
- package/README.md +249 -28
- package/dist/main.cjs +436 -32
- package/dist/main.cjs.map +1 -1
- package/dist/main.mjs +428 -33
- package/dist/main.mjs.map +1 -1
- package/dist/types.d.ts +2070 -66
- package/package.json +37 -24
- package/dist/types.d.ts.map +0 -1
- package/docs/README.md +0 -47
- package/docs/functions/Err.md +0 -46
- package/docs/functions/Ok.md +0 -70
- package/docs/functions/Some.md +0 -45
- package/docs/functions/isOption.md +0 -35
- package/docs/functions/isResult.md +0 -36
- package/docs/functions/promiseToAsyncResult.md +0 -50
- package/docs/interfaces/None.md +0 -850
- package/docs/interfaces/Option.md +0 -761
- package/docs/interfaces/Result.md +0 -777
- package/docs/type-aliases/AsyncIOResult.md +0 -24
- package/docs/type-aliases/AsyncOption.md +0 -24
- package/docs/type-aliases/AsyncResult.md +0 -25
- package/docs/type-aliases/AsyncVoidIOResult.md +0 -17
- package/docs/type-aliases/AsyncVoidResult.md +0 -23
- package/docs/type-aliases/IOResult.md +0 -24
- package/docs/type-aliases/VoidIOResult.md +0 -17
- package/docs/type-aliases/VoidResult.md +0 -23
- package/docs/variables/None.md +0 -18
- package/docs/variables/RESULT_FALSE.md +0 -18
- package/docs/variables/RESULT_TRUE.md +0 -18
- package/docs/variables/RESULT_VOID.md +0 -17
- package/docs/variables/RESULT_ZERO.md +0 -18
- package/src/enum/constants.ts +0 -30
- package/src/enum/core.ts +0 -569
- package/src/enum/defines.ts +0 -62
- package/src/enum/extensions.ts +0 -31
- package/src/enum/mod.ts +0 -6
- package/src/enum/prelude.ts +0 -549
- package/src/enum/symbols.ts +0 -9
- package/src/enum/utils.ts +0 -27
- package/src/mod.ts +0 -1
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
[**happy-rusty**](../README.md) • **Docs**
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[happy-rusty](../README.md) / AsyncIOResult
|
|
6
|
-
|
|
7
|
-
# Type Alias: AsyncIOResult\<T\>
|
|
8
|
-
|
|
9
|
-
```ts
|
|
10
|
-
type AsyncIOResult<T>: AsyncResult<T, Error>;
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Represents an asynchronous I/O operation that yields a `Result<T, Error>`.
|
|
14
|
-
This is a promise that resolves to `Ok(T)` if the I/O operation was successful, or `Err(Error)` if there was an error.
|
|
15
|
-
|
|
16
|
-
## Type Parameters
|
|
17
|
-
|
|
18
|
-
| Type Parameter | Description |
|
|
19
|
-
| ------ | ------ |
|
|
20
|
-
| `T` | The type of the value that is produced by a successful I/O operation. |
|
|
21
|
-
|
|
22
|
-
## Defined in
|
|
23
|
-
|
|
24
|
-
[defines.ts:52](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/defines.ts#L52)
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
[**happy-rusty**](../README.md) • **Docs**
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[happy-rusty](../README.md) / AsyncOption
|
|
6
|
-
|
|
7
|
-
# Type Alias: AsyncOption\<T\>
|
|
8
|
-
|
|
9
|
-
```ts
|
|
10
|
-
type AsyncOption<T>: Promise<Option<T>>;
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Represents an asynchronous operation that yields an `Option<T>`.
|
|
14
|
-
This is a promise that resolves to either `Some(T)` if the value is present, or `None` if the value is absent.
|
|
15
|
-
|
|
16
|
-
## Type Parameters
|
|
17
|
-
|
|
18
|
-
| Type Parameter | Description |
|
|
19
|
-
| ------ | ------ |
|
|
20
|
-
| `T` | The type of the value that may be contained within the `Option`. |
|
|
21
|
-
|
|
22
|
-
## Defined in
|
|
23
|
-
|
|
24
|
-
[defines.ts:13](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/defines.ts#L13)
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
[**happy-rusty**](../README.md) • **Docs**
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[happy-rusty](../README.md) / AsyncResult
|
|
6
|
-
|
|
7
|
-
# Type Alias: AsyncResult\<T, E\>
|
|
8
|
-
|
|
9
|
-
```ts
|
|
10
|
-
type AsyncResult<T, E>: Promise<Result<T, E>>;
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Represents an asynchronous operation that yields a `Result<T, E>`.
|
|
14
|
-
This is a promise that resolves to `Ok(T)` if the operation was successful, or `Err(E)` if there was an error.
|
|
15
|
-
|
|
16
|
-
## Type Parameters
|
|
17
|
-
|
|
18
|
-
| Type Parameter | Description |
|
|
19
|
-
| ------ | ------ |
|
|
20
|
-
| `T` | The type of the value that is produced by a successful operation. |
|
|
21
|
-
| `E` | The type of the error that may be produced by a failed operation. |
|
|
22
|
-
|
|
23
|
-
## Defined in
|
|
24
|
-
|
|
25
|
-
[defines.ts:22](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/defines.ts#L22)
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
[**happy-rusty**](../README.md) • **Docs**
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[happy-rusty](../README.md) / AsyncVoidIOResult
|
|
6
|
-
|
|
7
|
-
# Type Alias: AsyncVoidIOResult
|
|
8
|
-
|
|
9
|
-
```ts
|
|
10
|
-
type AsyncVoidIOResult: AsyncIOResult<void>;
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
`VoidIOResult` wrapped by `Promise`.
|
|
14
|
-
|
|
15
|
-
## Defined in
|
|
16
|
-
|
|
17
|
-
[defines.ts:62](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/defines.ts#L62)
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
[**happy-rusty**](../README.md) • **Docs**
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[happy-rusty](../README.md) / AsyncVoidResult
|
|
6
|
-
|
|
7
|
-
# Type Alias: AsyncVoidResult\<E\>
|
|
8
|
-
|
|
9
|
-
```ts
|
|
10
|
-
type AsyncVoidResult<E>: Promise<VoidResult<E>>;
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
`VoidResult<E>` wrapped by `Promise`.
|
|
14
|
-
|
|
15
|
-
## Type Parameters
|
|
16
|
-
|
|
17
|
-
| Type Parameter | Description |
|
|
18
|
-
| ------ | ------ |
|
|
19
|
-
| `E` | The type of the error that may be produced by a failed operation. |
|
|
20
|
-
|
|
21
|
-
## Defined in
|
|
22
|
-
|
|
23
|
-
[defines.ts:36](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/defines.ts#L36)
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
[**happy-rusty**](../README.md) • **Docs**
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[happy-rusty](../README.md) / IOResult
|
|
6
|
-
|
|
7
|
-
# Type Alias: IOResult\<T\>
|
|
8
|
-
|
|
9
|
-
```ts
|
|
10
|
-
type IOResult<T>: Result<T, Error>;
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Represents a synchronous operation that yields a `Result<T, Error>`.
|
|
14
|
-
This is a result that is either `Ok(T)` if the operation was successful, or `Err(Error)` if there was an error.
|
|
15
|
-
|
|
16
|
-
## Type Parameters
|
|
17
|
-
|
|
18
|
-
| Type Parameter | Description |
|
|
19
|
-
| ------ | ------ |
|
|
20
|
-
| `T` | The type of the value that is produced by a successful operation. |
|
|
21
|
-
|
|
22
|
-
## Defined in
|
|
23
|
-
|
|
24
|
-
[defines.ts:44](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/defines.ts#L44)
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
[**happy-rusty**](../README.md) • **Docs**
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[happy-rusty](../README.md) / VoidIOResult
|
|
6
|
-
|
|
7
|
-
# Type Alias: VoidIOResult
|
|
8
|
-
|
|
9
|
-
```ts
|
|
10
|
-
type VoidIOResult: IOResult<void>;
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Similar to Rust's `Result<(), Error>`.
|
|
14
|
-
|
|
15
|
-
## Defined in
|
|
16
|
-
|
|
17
|
-
[defines.ts:57](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/defines.ts#L57)
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
[**happy-rusty**](../README.md) • **Docs**
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[happy-rusty](../README.md) / VoidResult
|
|
6
|
-
|
|
7
|
-
# Type Alias: VoidResult\<E\>
|
|
8
|
-
|
|
9
|
-
```ts
|
|
10
|
-
type VoidResult<E>: Result<void, E>;
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Similar to Rust's `Result<(), E>`.
|
|
14
|
-
|
|
15
|
-
## Type Parameters
|
|
16
|
-
|
|
17
|
-
| Type Parameter | Description |
|
|
18
|
-
| ------ | ------ |
|
|
19
|
-
| `E` | The type of the error that may be produced by a failed operation. |
|
|
20
|
-
|
|
21
|
-
## Defined in
|
|
22
|
-
|
|
23
|
-
[defines.ts:29](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/defines.ts#L29)
|
package/docs/variables/None.md
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
[**happy-rusty**](../README.md) • **Docs**
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[happy-rusty](../README.md) / None
|
|
6
|
-
|
|
7
|
-
# Variable: None
|
|
8
|
-
|
|
9
|
-
```ts
|
|
10
|
-
None: None;
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
A constant representing the `None` case of an `Option`, indicating the absence of a value.
|
|
14
|
-
This constant is frozen to ensure it is immutable and cannot be altered, preserving the integrity of `None` throughout the application.
|
|
15
|
-
|
|
16
|
-
## Defined in
|
|
17
|
-
|
|
18
|
-
[prelude.ts:10](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/prelude.ts#L10)
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
[**happy-rusty**](../README.md) • **Docs**
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[happy-rusty](../README.md) / RESULT\_FALSE
|
|
6
|
-
|
|
7
|
-
# Variable: RESULT\_FALSE
|
|
8
|
-
|
|
9
|
-
```ts
|
|
10
|
-
const RESULT_FALSE: Result<boolean, any>;
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Result constant for `false`.
|
|
14
|
-
Can be used anywhere due to immutability.
|
|
15
|
-
|
|
16
|
-
## Defined in
|
|
17
|
-
|
|
18
|
-
[constants.ts:19](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/constants.ts#L19)
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
[**happy-rusty**](../README.md) • **Docs**
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[happy-rusty](../README.md) / RESULT\_TRUE
|
|
6
|
-
|
|
7
|
-
# Variable: RESULT\_TRUE
|
|
8
|
-
|
|
9
|
-
```ts
|
|
10
|
-
const RESULT_TRUE: Result<boolean, any>;
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Result constant for `true`.
|
|
14
|
-
Can be used anywhere due to immutability.
|
|
15
|
-
|
|
16
|
-
## Defined in
|
|
17
|
-
|
|
18
|
-
[constants.ts:13](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/constants.ts#L13)
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
[**happy-rusty**](../README.md) • **Docs**
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[happy-rusty](../README.md) / RESULT\_VOID
|
|
6
|
-
|
|
7
|
-
# Variable: RESULT\_VOID
|
|
8
|
-
|
|
9
|
-
```ts
|
|
10
|
-
const RESULT_VOID: Result<void, any>;
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Result constant for `void` or `()`.
|
|
14
|
-
|
|
15
|
-
## Defined in
|
|
16
|
-
|
|
17
|
-
[constants.ts:30](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/constants.ts#L30)
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
[**happy-rusty**](../README.md) • **Docs**
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[happy-rusty](../README.md) / RESULT\_ZERO
|
|
6
|
-
|
|
7
|
-
# Variable: RESULT\_ZERO
|
|
8
|
-
|
|
9
|
-
```ts
|
|
10
|
-
const RESULT_ZERO: Result<number, any>;
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Result constant for `0`.
|
|
14
|
-
Can be used anywhere due to immutability.
|
|
15
|
-
|
|
16
|
-
## Defined in
|
|
17
|
-
|
|
18
|
-
[constants.ts:25](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/constants.ts#L25)
|
package/src/enum/constants.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import type { Result } from './core.ts';
|
|
3
|
-
import { Ok } from './prelude.ts';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Exports some Result constants.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Result constant for `true`.
|
|
11
|
-
* Can be used anywhere due to immutability.
|
|
12
|
-
*/
|
|
13
|
-
export const RESULT_TRUE: Result<boolean, any> = Ok(true);
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Result constant for `false`.
|
|
17
|
-
* Can be used anywhere due to immutability.
|
|
18
|
-
*/
|
|
19
|
-
export const RESULT_FALSE: Result<boolean, any> = Ok(false);
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Result constant for `0`.
|
|
23
|
-
* Can be used anywhere due to immutability.
|
|
24
|
-
*/
|
|
25
|
-
export const RESULT_ZERO: Result<number, any> = Ok(0);
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Result constant for `void` or `()`.
|
|
29
|
-
*/
|
|
30
|
-
export const RESULT_VOID: Result<void, any> = Ok();
|