@@ -87,22 +87,25 @@ let asNullable = optString->Nullable.fromOption // Nullable.t<string>
8787let fromOption : option <'a > => t <'a >
8888
8989/**
90- `getWithDefault (value, default)` returns `value` if not `null` or `undefined`,
90+ `getOr (value, default)` returns `value` if not `null` or `undefined`,
9191otherwise return `default`.
9292
9393## Examples
9494
9595```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
9898
9999let greet = (firstName: option<string>) =>
100- "Greetings " ++ firstName->Nullable.getWithDefault ("Anonymous")
100+ "Greetings " ++ firstName->Nullable.getOr ("Anonymous")
101101
102102Nullable.make("Jane")->greet // "Greetings Jane"
103103Nullable.null->greet // "Greetings Anonymous"
104104```
105105*/
106+ let getOr : (t <'a >, 'a ) => 'a
107+
108+ @deprecated ("Use getOr instead" )
106109let getWithDefault : (t <'a >, 'a ) => 'a
107110
108111/**
@@ -149,19 +152,22 @@ Nullable.map(undefined, x => x * x) // undefined
149152let map : (t <'a >, 'a => 'b ) => t <'b >
150153
151154/**
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`
153156or `undefined`, otherwise returns `default`.
154157
155158## Examples
156159
157160```rescript
158161let someValue = Nullable.make(3)
159- someValue->Nullable.mapWithDefault (0, x => x + 5) // 8
162+ someValue->Nullable.mapOr (0, x => x + 5) // 8
160163
161164let noneValue = Nullable.null
162- noneValue->Nullable.mapWithDefault (0, x => x + 5) // 0
165+ noneValue->Nullable.mapOr (0, x => x + 5) // 0
163166```
164167*/
168+ let mapOr : (t <'a >, 'b , 'a => 'b ) => 'b
169+
170+ @deprecated ("Use mapOr instead" )
165171let mapWithDefault : (t <'a >, 'b , 'a => 'b ) => 'b
166172
167173/**
0 commit comments