whenIsOptionalEmpty
Applique une fonction uniquement lorsqu'un optional est vide (undefined).
Exemple interactif
Syntaxe
Signature classique
typescript
function whenIsOptionalEmpty<
const GenericInput extends unknown,
const GenericOutput extends AnyValue | EscapeVoid
>(
input: GenericInput,
theFunction: (value: Unwrap<Extract<ToEither<GenericInput>, EitherOptionalEmpty>>) => GenericOutput
): GenericOutput | Exclude<ToEither<GenericInput>, EitherOptionalEmpty>;Signature currifiée
typescript
function whenIsOptionalEmpty<
const GenericInput extends unknown,
const GenericOutput extends AnyValue | EscapeVoid
>(
theFunction: (value: Unwrap<Extract<ToEither<GenericInput>, EitherOptionalEmpty>>) => GenericOutput
): (input: GenericInput) => GenericOutput | Exclude<ToEither<GenericInput>, EitherOptionalEmpty>;Paramètres
theFunction: Callback exécuté si la valeur estundefined.input: Valeur/Either à analyser.
Valeur de retour
Résultat du callback si vide, sinon valeur initiale.
