swappedNullishOrFn()
swappedNullishOrFn<
T,A>(a): <B>(b) => (c) =>A|NonNullable<B>
Swapped Nullish Coalescing (b(x) ?? a(x)).
Type Parameters
T
T
The type of the input value of the functions.
A
A
The return type of the first function.
Parameters
a
(x) => A
The function to get the fallback return of.
Returns
<
B>(b): (c) =>A|NonNullable<B>
Type Parameters
B
B
Parameters
b
(y) => B
Returns
(
c):A|NonNullable<B>
Parameters
c
T
Returns
A | NonNullable<B>
Remark
pure function
Example
swappedNullishOrFn(x => x.bar)(x => x.foo)({ bar: 4 });
// 4