Package: effect
Module: UndefinedOr
Pattern matches on an A | undefined value, running onDefined when the
value is present or evaluating onUndefined when the value is undefined.
When to use
Use when you need to turn an A | undefined into a non-optional result by
handling both the defined and undefined branches in one expression.
See
map for transforming defined values while preserving undefinedgetOrThrowWith for throwing when the value is undefined instead of returning a fallback branchSignature
declare const match: { <B, A, C = B>(options: { readonly onUndefined: LazyArg<B>; readonly onDefined: (a: A) => C; }): (self: A | undefined) => B | C; <A, B, C = B>(self: A | undefined, options: { readonly onUndefined: LazyArg<B>; readonly onDefined: (a: A) => C; }): B | C; }
Since v4.0.0