Skip to content

whenIsNullableEmpty

Executes a callback only when the Either is NullableEmpty.

Interactive example

Syntax

Classic signature

typescript
function whenIsNullableEmpty<
  const GenericInput extends unknown,
  const GenericOutput extends AnyValue | EscapeVoid
>(
  input: GenericInput,
  theFunction: (value: Unwrap<Extract<ToEither<GenericInput>, EitherNullableEmpty>>) => GenericOutput
): GenericOutput | Exclude<ToEither<GenericInput>, EitherNullableEmpty>;

Curried signature

typescript
function whenIsNullableEmpty<
  const GenericInput extends unknown,
  const GenericOutput extends AnyValue | EscapeVoid
>(
  theFunction: (value: Unwrap<Extract<ToEither<GenericInput>, EitherNullableEmpty>>) => GenericOutput
): (input: GenericInput) => GenericOutput | Exclude<ToEither<GenericInput>, EitherNullableEmpty>;

Parameters

  • theFunction: Callback called when there is no value.
  • input: Value/Either to process.

Return value

Result of the callback if null, otherwise the original value.

See also

Released under the MIT license.