Skip to content

nullable

Wraps a null or non-null value in an Either, while keeping the information on whether it is filled or empty.

Interactive example

Syntax

typescript
function nullable<
	const GenericInput extends unknown = null
>(
  input: GenericInput
): GenericInput extends null
  ? EitherNullableEmpty
  : EitherNullableFilled<GenericInput>;

Parameters

  • input: Can be null or a concrete value.

Return value

  • EitherNullableFilled if the value exists.
  • EitherNullableEmpty if null.

See also

Released under the MIT license.