happy-rusty 1.3.2 → 1.5.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 +9 -28
- package/README.md +9 -28
- package/dist/main.cjs +56 -0
- package/dist/main.cjs.map +1 -1
- package/dist/main.mjs +56 -1
- package/dist/main.mjs.map +1 -1
- package/dist/types.d.ts +93 -11
- package/docs/README.md +5 -0
- package/docs/functions/Err.md +1 -1
- package/docs/functions/Ok.md +30 -6
- package/docs/functions/Some.md +1 -1
- package/docs/functions/isOption.md +1 -1
- package/docs/functions/isResult.md +1 -1
- package/docs/functions/promiseToAsyncResult.md +1 -1
- package/docs/interfaces/None.md +175 -46
- package/docs/interfaces/Option.md +128 -32
- package/docs/interfaces/Result.md +160 -34
- package/docs/type-aliases/AsyncIOResult.md +1 -1
- package/docs/type-aliases/AsyncOption.md +1 -1
- package/docs/type-aliases/AsyncResult.md +1 -1
- package/docs/type-aliases/AsyncVoidIOResult.md +17 -0
- package/docs/type-aliases/AsyncVoidResult.md +23 -0
- package/docs/type-aliases/IOResult.md +1 -1
- package/docs/type-aliases/VoidIOResult.md +17 -0
- package/docs/type-aliases/VoidResult.md +23 -0
- package/docs/variables/None.md +1 -1
- package/docs/variables/RESULT_FALSE.md +1 -1
- package/docs/variables/RESULT_TRUE.md +1 -1
- package/docs/variables/RESULT_VOID.md +17 -0
- package/docs/variables/RESULT_ZERO.md +1 -1
- package/package.json +5 -5
- package/src/enum/constants.ts +6 -1
- package/src/enum/core.ts +69 -3
- package/src/enum/defines.ts +17 -10
- package/src/enum/prelude.ts +89 -14
|
@@ -25,12 +25,6 @@ pub enum Result<T, E> {
|
|
|
25
25
|
| `T` | The type of the value contained in a successful `Result`. |
|
|
26
26
|
| `E` | The type of the error contained in an unsuccessful `Result`. |
|
|
27
27
|
|
|
28
|
-
## Properties
|
|
29
|
-
|
|
30
|
-
| Property | Type | Description | Defined in |
|
|
31
|
-
| ------ | ------ | ------ | ------ |
|
|
32
|
-
| `[toStringTag]` | `"Result"` | [object Result]. | [core.ts:304](https://github.com/JiangJie/happy-rusty/blob/d91a6123f053d528d1e11023507d8f0c72720848/src/enum/core.ts#L304) |
|
|
33
|
-
|
|
34
28
|
## Methods
|
|
35
29
|
|
|
36
30
|
### and()
|
|
@@ -61,7 +55,7 @@ The passed `Result` if `this` is `Ok`, otherwise returns `this` (which is `Err`)
|
|
|
61
55
|
|
|
62
56
|
#### Defined in
|
|
63
57
|
|
|
64
|
-
[core.ts:
|
|
58
|
+
[core.ts:528](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L528)
|
|
65
59
|
|
|
66
60
|
***
|
|
67
61
|
|
|
@@ -93,7 +87,37 @@ The result of `fn` if `this` is `Ok`, otherwise `this` as `Err`.
|
|
|
93
87
|
|
|
94
88
|
#### Defined in
|
|
95
89
|
|
|
96
|
-
[core.ts:
|
|
90
|
+
[core.ts:544](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L544)
|
|
91
|
+
|
|
92
|
+
***
|
|
93
|
+
|
|
94
|
+
### andThenAsync()
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
andThenAsync<U>(fn): AsyncResult<U, E>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Asynchronous version of `andThen`.
|
|
101
|
+
|
|
102
|
+
#### Type Parameters
|
|
103
|
+
|
|
104
|
+
| Type Parameter |
|
|
105
|
+
| ------ |
|
|
106
|
+
| `U` |
|
|
107
|
+
|
|
108
|
+
#### Parameters
|
|
109
|
+
|
|
110
|
+
| Parameter | Type |
|
|
111
|
+
| ------ | ------ |
|
|
112
|
+
| `fn` | (`value`) => [`AsyncResult`](../type-aliases/AsyncResult.md)\<`U`, `E`\> |
|
|
113
|
+
|
|
114
|
+
#### Returns
|
|
115
|
+
|
|
116
|
+
[`AsyncResult`](../type-aliases/AsyncResult.md)\<`U`, `E`\>
|
|
117
|
+
|
|
118
|
+
#### Defined in
|
|
119
|
+
|
|
120
|
+
[core.ts:549](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L549)
|
|
97
121
|
|
|
98
122
|
***
|
|
99
123
|
|
|
@@ -122,7 +146,7 @@ Just same as `result as unknown as Result<U, E>`.
|
|
|
122
146
|
|
|
123
147
|
#### Defined in
|
|
124
148
|
|
|
125
|
-
[core.ts:
|
|
149
|
+
[core.ts:612](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L612)
|
|
126
150
|
|
|
127
151
|
***
|
|
128
152
|
|
|
@@ -150,7 +174,7 @@ Just same as `result as unknown as Result<T, F>`.
|
|
|
150
174
|
|
|
151
175
|
#### Defined in
|
|
152
176
|
|
|
153
|
-
[core.ts:
|
|
177
|
+
[core.ts:601](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L601)
|
|
154
178
|
|
|
155
179
|
***
|
|
156
180
|
|
|
@@ -176,7 +200,7 @@ Tests whether `this` and `other` are both `Ok` containing equal values, or both
|
|
|
176
200
|
|
|
177
201
|
#### Defined in
|
|
178
202
|
|
|
179
|
-
[core.ts:
|
|
203
|
+
[core.ts:589](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L589)
|
|
180
204
|
|
|
181
205
|
***
|
|
182
206
|
|
|
@@ -196,7 +220,7 @@ If the result is `Ok`, returns `None`.
|
|
|
196
220
|
|
|
197
221
|
#### Defined in
|
|
198
222
|
|
|
199
|
-
[core.ts:
|
|
223
|
+
[core.ts:452](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L452)
|
|
200
224
|
|
|
201
225
|
***
|
|
202
226
|
|
|
@@ -224,7 +248,7 @@ Throws an error with the provided message if the result is an `Err`.
|
|
|
224
248
|
|
|
225
249
|
#### Defined in
|
|
226
250
|
|
|
227
|
-
[core.ts:
|
|
251
|
+
[core.ts:390](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L390)
|
|
228
252
|
|
|
229
253
|
***
|
|
230
254
|
|
|
@@ -252,7 +276,7 @@ Throws an error with the provided message if the result is an `Ok`.
|
|
|
252
276
|
|
|
253
277
|
#### Defined in
|
|
254
278
|
|
|
255
|
-
[core.ts:
|
|
279
|
+
[core.ts:424](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L424)
|
|
256
280
|
|
|
257
281
|
***
|
|
258
282
|
|
|
@@ -284,7 +308,7 @@ If the result is `Ok(Err(E))` or `Err(E)`, returns `Err(E)`.
|
|
|
284
308
|
|
|
285
309
|
#### Defined in
|
|
286
310
|
|
|
287
|
-
[core.ts:
|
|
311
|
+
[core.ts:512](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L512)
|
|
288
312
|
|
|
289
313
|
***
|
|
290
314
|
|
|
@@ -311,7 +335,7 @@ Does not modify the `Result`.
|
|
|
311
335
|
|
|
312
336
|
#### Defined in
|
|
313
337
|
|
|
314
|
-
[core.ts:
|
|
338
|
+
[core.ts:572](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L572)
|
|
315
339
|
|
|
316
340
|
***
|
|
317
341
|
|
|
@@ -338,7 +362,7 @@ Does not modify the `Result`.
|
|
|
338
362
|
|
|
339
363
|
#### Defined in
|
|
340
364
|
|
|
341
|
-
[core.ts:
|
|
365
|
+
[core.ts:580](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L580)
|
|
342
366
|
|
|
343
367
|
***
|
|
344
368
|
|
|
@@ -356,7 +380,7 @@ Returns `true` if the result is `Err`.
|
|
|
356
380
|
|
|
357
381
|
#### Defined in
|
|
358
382
|
|
|
359
|
-
[core.ts:
|
|
383
|
+
[core.ts:353](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L353)
|
|
360
384
|
|
|
361
385
|
***
|
|
362
386
|
|
|
@@ -380,7 +404,31 @@ Returns `true` if the result is `Err` and the provided predicate returns `true`
|
|
|
380
404
|
|
|
381
405
|
#### Defined in
|
|
382
406
|
|
|
383
|
-
[core.ts:
|
|
407
|
+
[core.ts:370](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L370)
|
|
408
|
+
|
|
409
|
+
***
|
|
410
|
+
|
|
411
|
+
### isErrAndAsync()
|
|
412
|
+
|
|
413
|
+
```ts
|
|
414
|
+
isErrAndAsync(predicate): Promise<boolean>
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
Asynchronous version of `isErrAnd`.
|
|
418
|
+
|
|
419
|
+
#### Parameters
|
|
420
|
+
|
|
421
|
+
| Parameter | Type |
|
|
422
|
+
| ------ | ------ |
|
|
423
|
+
| `predicate` | (`error`) => `Promise`\<`boolean`\> |
|
|
424
|
+
|
|
425
|
+
#### Returns
|
|
426
|
+
|
|
427
|
+
`Promise`\<`boolean`\>
|
|
428
|
+
|
|
429
|
+
#### Defined in
|
|
430
|
+
|
|
431
|
+
[core.ts:375](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L375)
|
|
384
432
|
|
|
385
433
|
***
|
|
386
434
|
|
|
@@ -398,7 +446,7 @@ Returns `true` if the result is `Ok`.
|
|
|
398
446
|
|
|
399
447
|
#### Defined in
|
|
400
448
|
|
|
401
|
-
[core.ts:
|
|
449
|
+
[core.ts:348](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L348)
|
|
402
450
|
|
|
403
451
|
***
|
|
404
452
|
|
|
@@ -422,7 +470,31 @@ Returns `true` if the result is `Ok` and the provided predicate returns `true` f
|
|
|
422
470
|
|
|
423
471
|
#### Defined in
|
|
424
472
|
|
|
425
|
-
[core.ts:
|
|
473
|
+
[core.ts:359](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L359)
|
|
474
|
+
|
|
475
|
+
***
|
|
476
|
+
|
|
477
|
+
### isOkAndAsync()
|
|
478
|
+
|
|
479
|
+
```ts
|
|
480
|
+
isOkAndAsync(predicate): Promise<boolean>
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
Asynchronous version of `isOkAnd`.
|
|
484
|
+
|
|
485
|
+
#### Parameters
|
|
486
|
+
|
|
487
|
+
| Parameter | Type |
|
|
488
|
+
| ------ | ------ |
|
|
489
|
+
| `predicate` | (`value`) => `Promise`\<`boolean`\> |
|
|
490
|
+
|
|
491
|
+
#### Returns
|
|
492
|
+
|
|
493
|
+
`Promise`\<`boolean`\>
|
|
494
|
+
|
|
495
|
+
#### Defined in
|
|
496
|
+
|
|
497
|
+
[core.ts:364](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L364)
|
|
426
498
|
|
|
427
499
|
***
|
|
428
500
|
|
|
@@ -453,7 +525,7 @@ leaving an `Err` value untouched.
|
|
|
453
525
|
|
|
454
526
|
#### Defined in
|
|
455
527
|
|
|
456
|
-
[core.ts:
|
|
528
|
+
[core.ts:473](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L473)
|
|
457
529
|
|
|
458
530
|
***
|
|
459
531
|
|
|
@@ -484,7 +556,7 @@ leaving an `Ok` value untouched.
|
|
|
484
556
|
|
|
485
557
|
#### Defined in
|
|
486
558
|
|
|
487
|
-
[core.ts:
|
|
559
|
+
[core.ts:485](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L485)
|
|
488
560
|
|
|
489
561
|
***
|
|
490
562
|
|
|
@@ -515,7 +587,7 @@ Maps a `Result<T, E>` to `U` by applying a function to the contained `Ok` value
|
|
|
515
587
|
|
|
516
588
|
#### Defined in
|
|
517
589
|
|
|
518
|
-
[core.ts:
|
|
590
|
+
[core.ts:497](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L497)
|
|
519
591
|
|
|
520
592
|
***
|
|
521
593
|
|
|
@@ -546,7 +618,7 @@ Maps a `Result<T, E>` to `U` by applying a function to the contained `Ok` value
|
|
|
546
618
|
|
|
547
619
|
#### Defined in
|
|
548
620
|
|
|
549
|
-
[core.ts:
|
|
621
|
+
[core.ts:505](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L505)
|
|
550
622
|
|
|
551
623
|
***
|
|
552
624
|
|
|
@@ -566,7 +638,7 @@ If the result is `Err`, returns `None`.
|
|
|
566
638
|
|
|
567
639
|
#### Defined in
|
|
568
640
|
|
|
569
|
-
[core.ts:
|
|
641
|
+
[core.ts:445](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L445)
|
|
570
642
|
|
|
571
643
|
***
|
|
572
644
|
|
|
@@ -598,7 +670,7 @@ Returns `this` if it is `Ok`, otherwise returns the passed `Result`.
|
|
|
598
670
|
|
|
599
671
|
#### Defined in
|
|
600
672
|
|
|
601
|
-
[core.ts:
|
|
673
|
+
[core.ts:536](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L536)
|
|
602
674
|
|
|
603
675
|
***
|
|
604
676
|
|
|
@@ -630,7 +702,37 @@ The result of `fn` if `this` is `Err`, otherwise `this` as `Ok`.
|
|
|
630
702
|
|
|
631
703
|
#### Defined in
|
|
632
704
|
|
|
633
|
-
[core.ts:
|
|
705
|
+
[core.ts:557](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L557)
|
|
706
|
+
|
|
707
|
+
***
|
|
708
|
+
|
|
709
|
+
### orElseAsync()
|
|
710
|
+
|
|
711
|
+
```ts
|
|
712
|
+
orElseAsync<F>(fn): AsyncResult<T, F>
|
|
713
|
+
```
|
|
714
|
+
|
|
715
|
+
Asynchronous version of `orElse`.
|
|
716
|
+
|
|
717
|
+
#### Type Parameters
|
|
718
|
+
|
|
719
|
+
| Type Parameter |
|
|
720
|
+
| ------ |
|
|
721
|
+
| `F` |
|
|
722
|
+
|
|
723
|
+
#### Parameters
|
|
724
|
+
|
|
725
|
+
| Parameter | Type |
|
|
726
|
+
| ------ | ------ |
|
|
727
|
+
| `fn` | (`error`) => [`AsyncResult`](../type-aliases/AsyncResult.md)\<`T`, `F`\> |
|
|
728
|
+
|
|
729
|
+
#### Returns
|
|
730
|
+
|
|
731
|
+
[`AsyncResult`](../type-aliases/AsyncResult.md)\<`T`, `F`\>
|
|
732
|
+
|
|
733
|
+
#### Defined in
|
|
734
|
+
|
|
735
|
+
[core.ts:562](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L562)
|
|
634
736
|
|
|
635
737
|
***
|
|
636
738
|
|
|
@@ -648,7 +750,7 @@ Custom `toString` implementation that uses the `Result`'s contained value.
|
|
|
648
750
|
|
|
649
751
|
#### Defined in
|
|
650
752
|
|
|
651
|
-
[core.ts:
|
|
753
|
+
[core.ts:617](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L617)
|
|
652
754
|
|
|
653
755
|
***
|
|
654
756
|
|
|
@@ -682,7 +784,7 @@ Transposes a `Result` of an `Option` into an `Option` of a `Result`.
|
|
|
682
784
|
|
|
683
785
|
#### Defined in
|
|
684
786
|
|
|
685
|
-
[core.ts:
|
|
787
|
+
[core.ts:461](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L461)
|
|
686
788
|
|
|
687
789
|
***
|
|
688
790
|
|
|
@@ -704,7 +806,7 @@ Throws an error if the result is an `Err`.
|
|
|
704
806
|
|
|
705
807
|
#### Defined in
|
|
706
808
|
|
|
707
|
-
[core.ts:
|
|
809
|
+
[core.ts:396](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L396)
|
|
708
810
|
|
|
709
811
|
***
|
|
710
812
|
|
|
@@ -726,7 +828,7 @@ Throws an error if the result is an `Ok`.
|
|
|
726
828
|
|
|
727
829
|
#### Defined in
|
|
728
830
|
|
|
729
|
-
[core.ts:
|
|
831
|
+
[core.ts:430](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L430)
|
|
730
832
|
|
|
731
833
|
***
|
|
732
834
|
|
|
@@ -750,7 +852,7 @@ Returns the contained `Ok` value or a provided default.
|
|
|
750
852
|
|
|
751
853
|
#### Defined in
|
|
752
854
|
|
|
753
|
-
[core.ts:
|
|
855
|
+
[core.ts:402](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L402)
|
|
754
856
|
|
|
755
857
|
***
|
|
756
858
|
|
|
@@ -774,4 +876,28 @@ Returns the contained `Ok` value or computes it from a closure if the result is
|
|
|
774
876
|
|
|
775
877
|
#### Defined in
|
|
776
878
|
|
|
777
|
-
[core.ts:
|
|
879
|
+
[core.ts:408](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L408)
|
|
880
|
+
|
|
881
|
+
***
|
|
882
|
+
|
|
883
|
+
### unwrapOrElseAsync()
|
|
884
|
+
|
|
885
|
+
```ts
|
|
886
|
+
unwrapOrElseAsync(fn): Promise<T>
|
|
887
|
+
```
|
|
888
|
+
|
|
889
|
+
Asynchronous version of `unwrapOrElse`.
|
|
890
|
+
|
|
891
|
+
#### Parameters
|
|
892
|
+
|
|
893
|
+
| Parameter | Type |
|
|
894
|
+
| ------ | ------ |
|
|
895
|
+
| `fn` | (`error`) => `Promise`\<`T`\> |
|
|
896
|
+
|
|
897
|
+
#### Returns
|
|
898
|
+
|
|
899
|
+
`Promise`\<`T`\>
|
|
900
|
+
|
|
901
|
+
#### Defined in
|
|
902
|
+
|
|
903
|
+
[core.ts:413](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L413)
|
|
@@ -21,4 +21,4 @@ This is a promise that resolves to `Ok(T)` if the I/O operation was successful,
|
|
|
21
21
|
|
|
22
22
|
## Defined in
|
|
23
23
|
|
|
24
|
-
[defines.ts:
|
|
24
|
+
[defines.ts:35](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/defines.ts#L35)
|
|
@@ -21,4 +21,4 @@ This is a promise that resolves to either `Some(T)` if the value is present, or
|
|
|
21
21
|
|
|
22
22
|
## Defined in
|
|
23
23
|
|
|
24
|
-
[
|
|
24
|
+
[core.ts:626](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L626)
|
|
@@ -22,4 +22,4 @@ This is a promise that resolves to `Ok(T)` if the operation was successful, or `
|
|
|
22
22
|
|
|
23
23
|
## Defined in
|
|
24
24
|
|
|
25
|
-
[
|
|
25
|
+
[core.ts:635](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L635)
|
|
@@ -0,0 +1,17 @@
|
|
|
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:45](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/defines.ts#L45)
|
|
@@ -0,0 +1,23 @@
|
|
|
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:19](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/defines.ts#L19)
|
|
@@ -21,4 +21,4 @@ This is a result that is either `Ok(T)` if the operation was successful, or `Err
|
|
|
21
21
|
|
|
22
22
|
## Defined in
|
|
23
23
|
|
|
24
|
-
[defines.ts:
|
|
24
|
+
[defines.ts:27](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/defines.ts#L27)
|
|
@@ -0,0 +1,17 @@
|
|
|
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:40](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/defines.ts#L40)
|
|
@@ -0,0 +1,23 @@
|
|
|
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:12](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/defines.ts#L12)
|
package/docs/variables/None.md
CHANGED
|
@@ -15,4 +15,4 @@ This constant is frozen to ensure it is immutable and cannot be altered, preserv
|
|
|
15
15
|
|
|
16
16
|
## Defined in
|
|
17
17
|
|
|
18
|
-
[prelude.ts:10](https://github.com/JiangJie/happy-rusty/blob/
|
|
18
|
+
[prelude.ts:10](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/prelude.ts#L10)
|
|
@@ -15,4 +15,4 @@ Can be used anywhere due to immutability.
|
|
|
15
15
|
|
|
16
16
|
## Defined in
|
|
17
17
|
|
|
18
|
-
[constants.ts:19](https://github.com/JiangJie/happy-rusty/blob/
|
|
18
|
+
[constants.ts:19](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/constants.ts#L19)
|
|
@@ -15,4 +15,4 @@ Can be used anywhere due to immutability.
|
|
|
15
15
|
|
|
16
16
|
## Defined in
|
|
17
17
|
|
|
18
|
-
[constants.ts:13](https://github.com/JiangJie/happy-rusty/blob/
|
|
18
|
+
[constants.ts:13](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/constants.ts#L13)
|
|
@@ -0,0 +1,17 @@
|
|
|
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/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/constants.ts#L30)
|
|
@@ -15,4 +15,4 @@ Can be used anywhere due to immutability.
|
|
|
15
15
|
|
|
16
16
|
## Defined in
|
|
17
17
|
|
|
18
|
-
[constants.ts:25](https://github.com/JiangJie/happy-rusty/blob/
|
|
18
|
+
[constants.ts:25](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/constants.ts#L25)
|
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.
|
|
6
|
+
"version": "1.5.0",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"source": "src/mod.ts",
|
|
9
9
|
"main": "dist/main.cjs",
|
|
@@ -48,16 +48,16 @@
|
|
|
48
48
|
"Err"
|
|
49
49
|
],
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@eslint/js": "^9.
|
|
51
|
+
"@eslint/js": "^9.9.0",
|
|
52
52
|
"@types/eslint__js": "^8.42.3",
|
|
53
|
-
"eslint": "^9.
|
|
53
|
+
"eslint": "^9.9.0",
|
|
54
54
|
"rollup": "^4.20.0",
|
|
55
55
|
"rollup-plugin-dts": "^6.1.1",
|
|
56
56
|
"rollup-plugin-esbuild": "^6.1.1",
|
|
57
57
|
"typedoc": "^0.26.5",
|
|
58
58
|
"typedoc-plugin-markdown": "^4.2.3",
|
|
59
59
|
"typescript": "^5.5.4",
|
|
60
|
-
"typescript-eslint": "^8.0.
|
|
60
|
+
"typescript-eslint": "^8.0.1"
|
|
61
61
|
},
|
|
62
|
-
"packageManager": "pnpm@9.
|
|
62
|
+
"packageManager": "pnpm@9.7.0"
|
|
63
63
|
}
|
package/src/enum/constants.ts
CHANGED
|
@@ -22,4 +22,9 @@ export const RESULT_FALSE: Result<boolean, any> = Ok(false);
|
|
|
22
22
|
* Result constant for `0`.
|
|
23
23
|
* Can be used anywhere due to immutability.
|
|
24
24
|
*/
|
|
25
|
-
export const RESULT_ZERO: Result<number, any> = Ok(0);
|
|
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();
|