happy-rusty 1.0.9 → 1.1.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.cn.md +15 -35
- package/README.md +15 -35
- package/dist/main.cjs +198 -19
- package/dist/main.cjs.map +1 -1
- package/dist/main.mjs +198 -20
- package/dist/main.mjs.map +1 -1
- package/dist/types.d.ts +521 -104
- package/docs/functions/Err.md +46 -0
- package/docs/functions/Ok.md +46 -0
- package/docs/functions/Some.md +45 -0
- package/docs/functions/promiseToResult.md +50 -0
- package/docs/index.md +37 -0
- package/docs/interfaces/None.md +827 -0
- package/docs/interfaces/Option.md +743 -0
- package/docs/interfaces/Result.md +702 -0
- package/docs/type-aliases/AsyncIOResult.md +24 -0
- package/docs/type-aliases/AsyncOption.md +24 -0
- package/docs/type-aliases/AsyncResult.md +25 -0
- package/docs/type-aliases/IOResult.md +24 -0
- package/docs/variables/None.md +18 -0
- package/package.json +16 -10
- package/src/enum/prelude.ts +965 -0
- package/src/mod.ts +13 -27
- package/src/enum/option.ts +0 -68
- package/src/enum/result.ts +0 -104
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[**happy-rusty**](../index.md) • **Docs**
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[happy-rusty](../index.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
|
+
## Source
|
|
23
|
+
|
|
24
|
+
[enum/prelude.ts:584](https://github.com/JiangJie/happy-rusty/blob/15ed105e08c6cc3943e22243c9386336a521d83e/src/enum/prelude.ts#L584)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[**happy-rusty**](../index.md) • **Docs**
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[happy-rusty](../index.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
|
+
## Source
|
|
24
|
+
|
|
25
|
+
[enum/prelude.ts:593](https://github.com/JiangJie/happy-rusty/blob/15ed105e08c6cc3943e22243c9386336a521d83e/src/enum/prelude.ts#L593)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[**happy-rusty**](../index.md) • **Docs**
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[happy-rusty](../index.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
|
+
## Source
|
|
23
|
+
|
|
24
|
+
[enum/prelude.ts:601](https://github.com/JiangJie/happy-rusty/blob/15ed105e08c6cc3943e22243c9386336a521d83e/src/enum/prelude.ts#L601)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
[**happy-rusty**](../index.md) • **Docs**
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[happy-rusty](../index.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
|
+
## Source
|
|
17
|
+
|
|
18
|
+
[enum/prelude.ts:288](https://github.com/JiangJie/happy-rusty/blob/15ed105e08c6cc3943e22243c9386336a521d83e/src/enum/prelude.ts#L288)
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Porting some excellent design implementations from Rust to JavaScript.",
|
|
4
4
|
"author": "jiang115jie@gmail.com",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
|
-
"version": "1.0
|
|
6
|
+
"version": "1.1.0",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"source": "src/mod.ts",
|
|
9
9
|
"main": "dist/main.cjs",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"README.md",
|
|
15
15
|
"README.cn.md",
|
|
16
16
|
"package.json",
|
|
17
|
+
"docs",
|
|
17
18
|
"src",
|
|
18
19
|
"dist"
|
|
19
20
|
],
|
|
@@ -21,9 +22,14 @@
|
|
|
21
22
|
"scripts": {
|
|
22
23
|
"check": "pnpm exec tsc --noEmit",
|
|
23
24
|
"lint": "pnpm exec eslint src/",
|
|
24
|
-
"prebuild": "pnpm
|
|
25
|
+
"prebuild": "pnpm dlx rimraf dist && pnpm run check && pnpm run lint",
|
|
25
26
|
"build": "pnpm exec rollup --config rollup.config.mjs",
|
|
26
|
-
"
|
|
27
|
+
"pretest": "pnpm dlx rimraf coverage",
|
|
28
|
+
"test": "deno test --coverage && deno coverage coverage && deno coverage coverage --lcov --output=coverage/cov_profile.lcov",
|
|
29
|
+
"pretest:html": "pnpm run pretest",
|
|
30
|
+
"test:html": "deno test --coverage && deno coverage coverage && deno coverage coverage --html",
|
|
31
|
+
"predocs": "pnpm dlx rimraf docs",
|
|
32
|
+
"docs": "pnpm exec typedoc",
|
|
27
33
|
"prepublishOnly": "pnpm run build"
|
|
28
34
|
},
|
|
29
35
|
"repository": {
|
|
@@ -41,15 +47,15 @@
|
|
|
41
47
|
"Err"
|
|
42
48
|
],
|
|
43
49
|
"devDependencies": {
|
|
44
|
-
"@
|
|
45
|
-
"@typescript-eslint/
|
|
46
|
-
"@typescript-eslint/parser": "^7.8.0",
|
|
50
|
+
"@typescript-eslint/eslint-plugin": "^7.12.0",
|
|
51
|
+
"@typescript-eslint/parser": "^7.12.0",
|
|
47
52
|
"eslint": "^8.57.0",
|
|
48
|
-
"
|
|
49
|
-
"rollup": "^
|
|
50
|
-
"rollup-plugin-dts": "^6.1.0",
|
|
53
|
+
"rollup": "^4.18.0",
|
|
54
|
+
"rollup-plugin-dts": "^6.1.1",
|
|
51
55
|
"rollup-plugin-esbuild": "^6.1.1",
|
|
56
|
+
"typedoc": "^0.25.13",
|
|
57
|
+
"typedoc-plugin-markdown": "^4.0.3",
|
|
52
58
|
"typescript": "^5.4.5"
|
|
53
59
|
},
|
|
54
|
-
"packageManager": "pnpm@9.
|
|
60
|
+
"packageManager": "pnpm@9.2.0"
|
|
55
61
|
}
|