getOrElse<L, R> function

Task<R> Function(TaskEither<L, R> taskEither) getOrElse<L, R>(
  1. R onLeft(
    1. L left
    )
)

Unwrap the Either value. Resolves to the unwrapped Right value, but if the TaskEither is an Left, the onLeft callback determines the fallback value.

expect(
  await right('hello').chain(getOrElse(() => 'fallback'))(),
  'hello',
);
expect(
  await left('fail').chain(getOrElse(() => 'fallback'))(),
  'fallback',
);

Implementation

Task<R> Function(TaskEither<L, R> taskEither) getOrElse<L, R>(
  R Function(L left) onLeft,
) =>
    task.map(either.getOrElse(onLeft));