unwrapSelection
Unwraps selected Either payloads from an exhaustive information selector, otherwise returns the original input unchanged.
The selector maps every possible information of the input union to true or false. A true entry unwraps the matching payload; a false entry keeps the original Either.
Interactive example
Syntax
Classic signature
typescript
function unwrapSelection<
GenericInput extends unknown,
GenericSelector extends Record<Information, boolean>,
>(
input: GenericInput,
selector: GenericSelector,
): UnwrappedSelectedInputs | UnselectedInputsCurried signature
typescript
function unwrapSelection<
GenericInput extends unknown,
GenericSelector extends Record<Information, boolean>,
>(
selector: GenericSelector,
): (input: GenericInput) => UnwrappedSelectedInputs | UnselectedInputsParameters
selector: Exhaustive object where each possible input information is mapped totrueorfalse.input: Either value to unwrap immediately, or later through the curried form.
Return value
Returns the unwrapped payload when the current information is selected with true. Otherwise, returns the original input unchanged.
When a selector entry is typed as boolean, the return type includes both possibilities for that information.
See also
unwrapSelectionOrThrow– Throwing variant when the current information is not selected.matchInformation– Exhaustive callback-based matching by information.unwrapByInformation– Selects informations from a string or string array.
