@@ -87,22 +87,25 @@ let asNullable = optString->Nullable.fromOption // Nullable.t<string>
87
87
let fromOption: option<'a> => t<'a>
88
88
89
89
/**
90
- `getWithDefault (value, default)` returns `value` if not `null` or `undefined`,
90
+ `getOr (value, default)` returns `value` if not `null` or `undefined`,
91
91
otherwise return `default`.
92
92
93
93
## Examples
94
94
95
95
```rescript
96
- Nullable.getWithDefault (Nullable.null, "Banana") // Banana
97
- Nullable.getWithDefault (Nulalble.make("Apple"), "Banana") // Apple
96
+ Nullable.getOr (Nullable.null, "Banana") // Banana
97
+ Nullable.getOr (Nulalble.make("Apple"), "Banana") // Apple
98
98
99
99
let greet = (firstName: option<string>) =>
100
- "Greetings " ++ firstName->Nullable.getWithDefault ("Anonymous")
100
+ "Greetings " ++ firstName->Nullable.getOr ("Anonymous")
101
101
102
102
Nullable.make("Jane")->greet // "Greetings Jane"
103
103
Nullable.null->greet // "Greetings Anonymous"
104
104
```
105
105
*/
106
+ let getOr: (t<'a>, 'a) => 'a
107
+
108
+ @deprecated("Use getOr instead")
106
109
let getWithDefault: (t<'a>, 'a) => 'a
107
110
108
111
/**
@@ -149,19 +152,22 @@ Nullable.map(undefined, x => x * x) // undefined
149
152
let map: (t<'a>, 'a => 'b) => t<'b>
150
153
151
154
/**
152
- `mapWithDefault (value, default, f)` returns `f(value)` if `value` is not `null`
155
+ `mapOr (value, default, f)` returns `f(value)` if `value` is not `null`
153
156
or `undefined`, otherwise returns `default`.
154
157
155
158
## Examples
156
159
157
160
```rescript
158
161
let someValue = Nullable.make(3)
159
- someValue->Nullable.mapWithDefault (0, x => x + 5) // 8
162
+ someValue->Nullable.mapOr (0, x => x + 5) // 8
160
163
161
164
let noneValue = Nullable.null
162
- noneValue->Nullable.mapWithDefault (0, x => x + 5) // 0
165
+ noneValue->Nullable.mapOr (0, x => x + 5) // 0
163
166
```
164
167
*/
168
+ let mapOr: (t<'a>, 'b, 'a => 'b) => 'b
169
+
170
+ @deprecated("Use mapOr instead")
165
171
let mapWithDefault: (t<'a>, 'b, 'a => 'b) => 'b
166
172
167
173
/**
0 commit comments