happy-rusty 1.4.0 → 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.
@@ -27,12 +27,6 @@ pub enum Option<T> {
27
27
  | ------ | ------ |
28
28
  | `T` | The type of the value contained in the `Some` variant. |
29
29
 
30
- ## Properties
31
-
32
- | Property | Type | Description | Defined in |
33
- | ------ | ------ | ------ | ------ |
34
- | `[toStringTag]` | `"Option"` | [object Option]. | [core.ts:30](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/core.ts#L30) |
35
-
36
30
  ## Methods
37
31
 
38
32
  ### and()
@@ -64,7 +58,7 @@ This is sometimes called "and then" because it is similar to a logical AND opera
64
58
 
65
59
  #### Defined in
66
60
 
67
- [core.ts:220](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/core.ts#L220)
61
+ [core.ts:232](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L232)
68
62
 
69
63
  ***
70
64
 
@@ -97,7 +91,37 @@ The result of `fn` if `this` is `Some`, otherwise `None`.
97
91
 
98
92
  #### Defined in
99
93
 
100
- [core.ts:229](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/core.ts#L229)
94
+ [core.ts:241](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L241)
95
+
96
+ ***
97
+
98
+ ### andThenAsync()
99
+
100
+ ```ts
101
+ andThenAsync<U>(fn): AsyncOption<U>
102
+ ```
103
+
104
+ Asynchronous version of `andThen`.
105
+
106
+ #### Type Parameters
107
+
108
+ | Type Parameter |
109
+ | ------ |
110
+ | `U` |
111
+
112
+ #### Parameters
113
+
114
+ | Parameter | Type |
115
+ | ------ | ------ |
116
+ | `fn` | (`value`) => [`AsyncOption`](../type-aliases/AsyncOption.md)\<`U`\> |
117
+
118
+ #### Returns
119
+
120
+ [`AsyncOption`](../type-aliases/AsyncOption.md)\<`U`\>
121
+
122
+ #### Defined in
123
+
124
+ [core.ts:246](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L246)
101
125
 
102
126
  ***
103
127
 
@@ -124,7 +148,7 @@ This method can be used for comparing `Option` instances in a value-sensitive ma
124
148
 
125
149
  #### Defined in
126
150
 
127
- [core.ts:273](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/core.ts#L273)
151
+ [core.ts:295](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L295)
128
152
 
129
153
  ***
130
154
 
@@ -152,7 +176,7 @@ Throws an error with the provided message if the Option is a `None`.
152
176
 
153
177
  #### Defined in
154
178
 
155
- [core.ts:76](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/core.ts#L76)
179
+ [core.ts:83](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L83)
156
180
 
157
181
  ***
158
182
 
@@ -178,7 +202,7 @@ Returns `None` if the Option is `None`, otherwise calls predicate with the wrapp
178
202
 
179
203
  #### Defined in
180
204
 
181
- [core.ts:138](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/core.ts#L138)
205
+ [core.ts:150](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L150)
182
206
 
183
207
  ***
184
208
 
@@ -210,7 +234,7 @@ Converts from `Option<Option<T>>` to `Option<T>`.
210
234
 
211
235
  #### Defined in
212
236
 
213
- [core.ts:144](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/core.ts#L144)
237
+ [core.ts:156](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L156)
214
238
 
215
239
  ***
216
240
 
@@ -237,7 +261,7 @@ This is primarily for side effects and does not transform the `Option`.
237
261
 
238
262
  #### Defined in
239
263
 
240
- [core.ts:263](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/core.ts#L263)
264
+ [core.ts:285](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L285)
241
265
 
242
266
  ***
243
267
 
@@ -255,7 +279,7 @@ Returns `true` if the Option is a `None` value.
255
279
 
256
280
  #### Defined in
257
281
 
258
- [core.ts:55](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/core.ts#L55)
282
+ [core.ts:57](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L57)
259
283
 
260
284
  ***
261
285
 
@@ -273,7 +297,7 @@ Returns `true` if the Option is a `Some` value.
273
297
 
274
298
  #### Defined in
275
299
 
276
- [core.ts:50](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/core.ts#L50)
300
+ [core.ts:52](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L52)
277
301
 
278
302
  ***
279
303
 
@@ -297,7 +321,31 @@ Returns `true` if the Option is a `Some` value and the predicate returns `true`
297
321
 
298
322
  #### Defined in
299
323
 
300
- [core.ts:61](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/core.ts#L61)
324
+ [core.ts:63](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L63)
325
+
326
+ ***
327
+
328
+ ### isSomeAndAsync()
329
+
330
+ ```ts
331
+ isSomeAndAsync(predicate): Promise<boolean>
332
+ ```
333
+
334
+ Asynchronous version of `isSomeAnd`.
335
+
336
+ #### Parameters
337
+
338
+ | Parameter | Type |
339
+ | ------ | ------ |
340
+ | `predicate` | (`value`) => `Promise`\<`boolean`\> |
341
+
342
+ #### Returns
343
+
344
+ `Promise`\<`boolean`\>
345
+
346
+ #### Defined in
347
+
348
+ [core.ts:68](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L68)
301
349
 
302
350
  ***
303
351
 
@@ -327,7 +375,7 @@ Maps an `Option<T>` to `Option<U>` by applying a function to a contained value.
327
375
 
328
376
  #### Defined in
329
377
 
330
- [core.ts:151](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/core.ts#L151)
378
+ [core.ts:163](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L163)
331
379
 
332
380
  ***
333
381
 
@@ -358,7 +406,7 @@ Maps an `Option<T>` to `U` by applying a function to the contained value (if any
358
406
 
359
407
  #### Defined in
360
408
 
361
- [core.ts:159](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/core.ts#L159)
409
+ [core.ts:171](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L171)
362
410
 
363
411
  ***
364
412
 
@@ -389,7 +437,7 @@ Maps an `Option<T>` to `U` by applying a function to a contained value (if any),
389
437
 
390
438
  #### Defined in
391
439
 
392
- [core.ts:167](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/core.ts#L167)
440
+ [core.ts:179](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L179)
393
441
 
394
442
  ***
395
443
 
@@ -419,7 +467,7 @@ Transforms the `Option<T>` into a `Result<T, E>`, mapping `Some(v)` to `Ok(v)` a
419
467
 
420
468
  #### Defined in
421
469
 
422
- [core.ts:109](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/core.ts#L109)
470
+ [core.ts:121](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L121)
423
471
 
424
472
  ***
425
473
 
@@ -449,7 +497,7 @@ Transforms the `Option<T>` into a `Result<T, E>`, mapping `Some(v)` to `Ok(v)` a
449
497
 
450
498
  #### Defined in
451
499
 
452
- [core.ts:116](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/core.ts#L116)
500
+ [core.ts:128](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L128)
453
501
 
454
502
  ***
455
503
 
@@ -476,7 +524,7 @@ This can be used for providing a fallback `Option`.
476
524
 
477
525
  #### Defined in
478
526
 
479
- [core.ts:237](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/core.ts#L237)
527
+ [core.ts:254](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L254)
480
528
 
481
529
  ***
482
530
 
@@ -503,7 +551,31 @@ This method can be used for lazy fallbacks, as `fn` is only evaluated if `this`
503
551
 
504
552
  #### Defined in
505
553
 
506
- [core.ts:245](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/core.ts#L245)
554
+ [core.ts:262](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L262)
555
+
556
+ ***
557
+
558
+ ### orElseAsync()
559
+
560
+ ```ts
561
+ orElseAsync(fn): AsyncOption<T>
562
+ ```
563
+
564
+ Asynchronous version of `orElse`.
565
+
566
+ #### Parameters
567
+
568
+ | Parameter | Type |
569
+ | ------ | ------ |
570
+ | `fn` | () => [`AsyncOption`](../type-aliases/AsyncOption.md)\<`T`\> |
571
+
572
+ #### Returns
573
+
574
+ [`AsyncOption`](../type-aliases/AsyncOption.md)\<`T`\>
575
+
576
+ #### Defined in
577
+
578
+ [core.ts:267](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L267)
507
579
 
508
580
  ***
509
581
 
@@ -521,7 +593,7 @@ Custom `toString` implementation that uses the `Option`'s contained value.
521
593
 
522
594
  #### Defined in
523
595
 
524
- [core.ts:280](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/core.ts#L280)
596
+ [core.ts:302](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L302)
525
597
 
526
598
  ***
527
599
 
@@ -556,7 +628,7 @@ Transposes an `Option` of a `Result` into a `Result` of an `Option`.
556
628
 
557
629
  #### Defined in
558
630
 
559
- [core.ts:126](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/core.ts#L126)
631
+ [core.ts:138](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L138)
560
632
 
561
633
  ***
562
634
 
@@ -578,7 +650,7 @@ Throws an error if the value is a `None`.
578
650
 
579
651
  #### Defined in
580
652
 
581
- [core.ts:82](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/core.ts#L82)
653
+ [core.ts:89](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L89)
582
654
 
583
655
  ***
584
656
 
@@ -602,7 +674,7 @@ Returns the contained `Some` value or a provided default.
602
674
 
603
675
  #### Defined in
604
676
 
605
- [core.ts:88](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/core.ts#L88)
677
+ [core.ts:95](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L95)
606
678
 
607
679
  ***
608
680
 
@@ -626,7 +698,31 @@ Returns the contained `Some` value or computes it from a closure.
626
698
 
627
699
  #### Defined in
628
700
 
629
- [core.ts:94](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/core.ts#L94)
701
+ [core.ts:101](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L101)
702
+
703
+ ***
704
+
705
+ ### unwrapOrElseAsync()
706
+
707
+ ```ts
708
+ unwrapOrElseAsync(fn): Promise<T>
709
+ ```
710
+
711
+ Asynchronous version of `unwrapOrElse`.
712
+
713
+ #### Parameters
714
+
715
+ | Parameter | Type |
716
+ | ------ | ------ |
717
+ | `fn` | () => `Promise`\<`T`\> |
718
+
719
+ #### Returns
720
+
721
+ `Promise`\<`T`\>
722
+
723
+ #### Defined in
724
+
725
+ [core.ts:106](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L106)
630
726
 
631
727
  ***
632
728
 
@@ -661,7 +757,7 @@ A tuple of `Options`, one for each element in the original `Option` of a tuple.
661
757
 
662
758
  #### Defined in
663
759
 
664
- [core.ts:203](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/core.ts#L203)
760
+ [core.ts:215](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L215)
665
761
 
666
762
  ***
667
763
 
@@ -688,7 +784,7 @@ This can be thought of as an exclusive or operation on `Option` values.
688
784
 
689
785
  #### Defined in
690
786
 
691
- [core.ts:253](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/core.ts#L253)
787
+ [core.ts:275](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L275)
692
788
 
693
789
  ***
694
790
 
@@ -722,7 +818,7 @@ An `Option` containing a tuple of the values if both are `Some`, otherwise `None
722
818
 
723
819
  #### Defined in
724
820
 
725
- [core.ts:181](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/core.ts#L181)
821
+ [core.ts:193](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L193)
726
822
 
727
823
  ***
728
824
 
@@ -758,4 +854,4 @@ An `Option` containing the result of `fn` if both `Options` are `Some`, otherwis
758
854
 
759
855
  #### Defined in
760
856
 
761
- [core.ts:193](https://github.com/JiangJie/happy-rusty/blob/7d7f4ab2132e507f77594d030495f95b5688b84a/src/enum/core.ts#L193)
857
+ [core.ts:205](https://github.com/JiangJie/happy-rusty/blob/6efe20969984552f52d79aee092bb6925a077fe7/src/enum/core.ts#L205)