@@ -44,14 +44,12 @@ val keepU : 'a option -> ('a -> bool [@bs]) -> 'a option
44
44
45
45
val keep : 'a option -> ('a -> bool ) -> 'a option
46
46
(* *
47
- `keep optionValue p `
47
+ If ` optionValue` is `Some(value)` and `p(value) = true`, it returns `Some(value)`; otherwise returns `None `
48
48
49
- If `optionValue` is `Some value` and `p value = true`, it returns `Some value`; otherwise returns `None`
50
-
51
- ```
52
- keep (Some 10)(fun x -> x > 5);; (* returns `Some 10` *)
53
- keep (Some 4)(fun x -> x > 5);; (* returns `None` *)
54
- keep None (fun x -> x > 5);; (* returns `None` *)
49
+ ```res example
50
+ Belt.Option.keep(Some(10), x => x > 5) /* returns `Some(10)` */
51
+ Belt.Option.keep(Some(4), x => x > 5) /* returns `None` */
52
+ Belt.Option.keep(None, x => x > 5) /* returns `None` */
55
53
```
56
54
*)
57
55
@@ -60,13 +58,11 @@ val forEachU : 'a option -> ('a -> unit [@bs]) -> unit
60
58
61
59
val forEach : 'a option -> ('a -> unit ) -> unit
62
60
(* *
63
- `forEach optionValue f`
64
-
65
- If `optionValue` is `Some value`, it calls `f value`; otherwise returns `()`
61
+ If `optionValue` is `Some(value`), it calls `f(value)`; otherwise returns `()`
66
62
67
- ```
68
- forEach (Some "thing")(fun x - > Js.log x);; ( * logs "thing" *)
69
- forEach None (fun x - > Js.log x);; ( * returns () *)
63
+ ```res example
64
+ Belt.Option. forEach(Some( "thing"), x = > Js.log(x)) / * logs "thing" */
65
+ Belt.Option. forEach( None, x = > Js.log(x)) / * returns () */
70
66
```
71
67
*)
72
68
@@ -83,9 +79,11 @@ val getExn : 'a option -> 'a
83
79
84
80
external getUnsafe :
85
81
'a option -> 'a = " %identity"
86
- (* * `getUnsafe x` returns x
87
- This is an unsafe operation, it assumes x is neither not None
88
- or (Some (None .. ))
82
+ (* *
83
+ `getUnsafe(x)` returns `x`
84
+
85
+ This is an unsafe operation, it assumes `x` is neither `None`
86
+ nor `Some(None(...)))`
89
87
*)
90
88
91
89
val mapWithDefaultU : 'a option -> 'b -> ('a -> 'b [@ bs]) -> 'b
0 commit comments