@@ -83,22 +83,25 @@ let asNullable = optString->Nullable.fromOption // Nullable.t<string>
8383let fromOption : option <'a > => t <'a >
8484
8585/**
86- `getWithDefault (value, default)` returns `value` if not `null` or `undefined`,
86+ `getOr (value, default)` returns `value` if not `null` or `undefined`,
8787otherwise return `default`.
8888
8989## Examples
9090
9191```rescript
92- Nullable.getWithDefault (Nullable.null, "Banana") // Banana
93- Nullable.getWithDefault (Nulalble.make("Apple"), "Banana") // Apple
92+ Nullable.getOr (Nullable.null, "Banana") // Banana
93+ Nullable.getOr (Nulalble.make("Apple"), "Banana") // Apple
9494
9595let greet = (firstName: option<string>) =>
96- "Greetings " ++ firstName->Nullable.getWithDefault ("Anonymous")
96+ "Greetings " ++ firstName->Nullable.getOr ("Anonymous")
9797
9898Nullable.make("Jane")->greet // "Greetings Jane"
9999Nullable.null->greet // "Greetings Anonymous"
100100```
101101*/
102+ let getOr : (t <'a >, 'a ) => 'a
103+
104+ @deprecated ("Use getOr instead" )
102105let getWithDefault : (t <'a >, 'a ) => 'a
103106
104107/**
@@ -145,19 +148,22 @@ Nullable.map(undefined, x => x * x) // undefined
145148let map : (t <'a >, 'a => 'b ) => t <'b >
146149
147150/**
148- `mapWithDefault (value, default, f)` returns `f(value)` if `value` is not `null`
151+ `mapOr (value, default, f)` returns `f(value)` if `value` is not `null`
149152or `undefined`, otherwise returns `default`.
150153
151154## Examples
152155
153156```rescript
154157let someValue = Nullable.make(3)
155- someValue->Nullable.mapWithDefault (0, x => x + 5) // 8
158+ someValue->Nullable.mapOr (0, x => x + 5) // 8
156159
157160let noneValue = Nullable.null
158- noneValue->Nullable.mapWithDefault (0, x => x + 5) // 0
161+ noneValue->Nullable.mapOr (0, x => x + 5) // 0
159162```
160163*/
164+ let mapOr : (t <'a >, 'b , 'a => 'b ) => 'b
165+
166+ @deprecated ("Use mapOr instead" )
161167let mapWithDefault : (t <'a >, 'b , 'a => 'b ) => 'b
162168
163169/**
0 commit comments