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>, NullishFilled>>) => GenericOutput
): GenericOutput | Exclude<ToEither<GenericInput>, NullishFilled>;

Curried signature ​

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

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.