Skip to content

toWrappedValue

The toWrappedValue() function ensures a value is wrapped: if it is already a WrappedValue, it is returned as is, otherwise it is wrapped.

Interactive example

Syntax

typescript
function toWrappedValue<
	GenericInnerValue extends AnyValue,
	GenericInput extends MaybeWrapped<GenericInnerValue>
>(
	input: GenericInput
): GenericInput extends WrappedValue ? GenericInput : WrappedValue<GenericInput>;

Parameters

  • input : Value (already wrapped or not) to normalize into a WrappedValue.

Return value

The wrapped value, or the initial value if it was already wrapped.

See also

Released under the MIT license.