unwrapByInformation
Unwrap le payload d'un Either lorsqu'une information littérale, ou l'une de plusieurs informations littérales, correspond; sinon renvoie l'entrée inchangée.
Exemple interactif
Syntaxe
Signature classique
typescript
function unwrapByInformation<
GenericInput extends unknown,
GenericInformation extends (
GenericInput extends Either
? ReturnType<typeof informationKind.getValue<GenericInput>>
: never
),
>(
input: GenericInput,
information: GenericInformation | GenericInformation[],
): GenericInput extends Kind<typeof informationKind.definition, GenericInformation>
? Unwrap<GenericInput>
: GenericInputSignature currifiée
typescript
function unwrapByInformation<
GenericInput extends unknown,
const GenericInformation extends (
GenericInput extends Either
? ReturnType<typeof informationKind.getValue<GenericInput>>
: never
),
>(
information: GenericInformation | GenericInformation[],
): (
input: GenericInput,
) => GenericInput extends Kind<typeof informationKind.definition, GenericInformation>
? Unwrap<GenericInput>
: GenericInputParamètres
information: Information littérale attendue, ou tableau d'informations littérales.input: ValeurEitherà unwrap immédiatement, ou plus tard via la forme currifiée.
Valeur de retour
Retourne le payload unwrap lorsqu'une information correspond. Si aucune information ne correspond, renvoie l'entrée originale inchangée.
Voir aussi
unwrapByInformationOrThrow– Variante qui lève une erreur quand l'information ne correspond pas.hasInformation– Contrôle non bloquant sur l'information littérale.whenHasInformation– Variante à callback.
