Skip to main content

Function: withFallback()

withFallback<T>(value: undefined | null | T, fallback: T): T

Defined in: src/utils/fallbacks.ts:171

Get value with fallback, checking for null/undefined.

Type Parametersโ€‹

Tโ€‹

T

Parametersโ€‹

valueโ€‹

The value to check for null or undefined

undefined | null | T

fallbackโ€‹

T

The fallback value to use if value is null or undefined

Returnsโ€‹

T

The original value if not null/undefined, otherwise the fallback