You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Provide a default value, turning an optional value into a normal value.
13
+
* @param defaultValue the default value to use if the Maybe is Nothing.
14
+
* @return the value of the Maybe, or the default value if it is Nothing.
15
+
* @example
16
+
* ```ts
17
+
* const maybeValue = Maybe.Just(42);
18
+
* const result = maybeValue.withDefault(0); // result is 42
19
+
* ...
20
+
* const maybeValue = Maybe.Nothing<number>();
21
+
* const result = maybeValue.withDefault(0); // result is 0
22
+
* ```
23
+
*/
24
+
withDefault(defaultValue: T): T;
25
+
/**
26
+
* Transform a Maybe value with a given function
27
+
* @param fn the function to apply to the value if it is Just.
28
+
* @return a new Maybe value, which is Just if the original was Just, or Nothing if it was Nothing.
29
+
* @example
30
+
* ```ts
31
+
* const maybeValue = Maybe.Just(42);
32
+
* const result = maybeValue.map(x => x * 2); // result is Just(84)
33
+
* ...
34
+
* const maybeValue = Maybe.Nothing<number>();
35
+
* const result = maybeValue.map(x => x * 2); // result is Nothing
36
+
* ```
37
+
*/
38
+
map<U>(fn: (value: T)=>U): Maybe<U>;
39
+
/**
40
+
* Chain together many computations that may fail.
41
+
* @param fn the function to apply to the value if it is Just.
42
+
* @return a new Maybe value, which is Just if the original was Just and the function returned Just, or Nothing if it was Nothing or the function returned Nothing.
0 commit comments