Skip to content

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>
  : GenericInput

Signature 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>
  : GenericInput

Paramètres

  • information : Information littérale attendue, ou tableau d'informations littérales.
  • input : Valeur Either à 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

Diffusé sous licence MIT.