File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,14 @@ function fromOption(option) {
9
9
10
10
}
11
11
12
+ function getWithDefault ( value , $$default ) {
13
+ if ( value == null ) {
14
+ return $$default ;
15
+ } else {
16
+ return value ;
17
+ }
18
+ }
19
+
12
20
function getExn ( value ) {
13
21
if ( ! ( value == null ) ) {
14
22
return value ;
@@ -22,6 +30,7 @@ function getExn(value) {
22
30
23
31
export {
24
32
fromOption ,
33
+ getWithDefault ,
25
34
getExn ,
26
35
}
27
36
/* No side effect */
Original file line number Diff line number Diff line change @@ -14,6 +14,12 @@ let fromOption: option<'a> => t<'a> = option =>
14
14
| None => undefined
15
15
}
16
16
17
+ let getWithDefault = (value , default ) =>
18
+ switch value -> toOption {
19
+ | Some (x ) => x
20
+ | None => default
21
+ }
22
+
17
23
let getExn : t <'a > => 'a = value =>
18
24
switch value -> toOption {
19
25
| Some (x ) => x
You can’t perform that action at this time.
0 commit comments