Skip to content

whenIsNullishFilled

Executes a callback only when the Either contains a defined value (NullishFilled).

Interactive example

Syntax

Classic signature

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

Curried signature

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

Parameters

  • theFunction: Callback applied when the value is present.
  • input: Value/Either to process.

Return value

Result of the callback or the original value if the Either was NullishEmpty.

See also

Released under the MIT license.