function providerValue
providerValue<T>(
provider: PaymentProviderType | null,
values: Readonly<Record<PaymentProviderType, T>>,
): T | null

Pick the value for the active payment provider from a per-provider set, or null when no provider is active. The set is keyed by the provider union, so a caller cannot forget a provider: leaving one out is a compile error at the call site rather than a silent null on a live site.

Type Parameters

Parameters

provider: PaymentProviderType | null
values: Readonly<Record<PaymentProviderType, T>>

Return Type

T | null

Usage

import { providerValue } from "doc.ts";