Skip to main content

nullishOrFn()

nullishOrFn<T, A>(a): <B>(b) => (c) => B | NonNullable<A>

Nullish Coalescing (a(x) ?? b(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, possibly null, return of.

Returns

<B>(b): (c) => B | NonNullable<A>

Type Parameters

B

B

Parameters

b

(y) => B

Returns

(c): B | NonNullable<A>

Parameters

c

T

Returns

B | NonNullable<A>

Remark

pure function

Example

nullishOrFn(x => x.foo)(x => x.bar)({ bar: 4 });
// 4