Helpful
    Preparing search index...

    Function optional

    Allows a value to be null or undefined and has a fallback.

    The value to check. This can be a promise that can return null or undefined in addition to the value.

    The fallback value in the case that val is null or undefined.

    The type of value that is being checked.

    This method returns val if it is not null or undefined, otherwise, the fallback is returned. If val is a promise and rejects, then fallback is also returned.

    • Allows a value to be null or undefined and has a fallback.

      Type Parameters

      • T

        The type of value that is being checked.

      Parameters

      • val: ZObligatedValue<T>

        The value to check. This can be a promise that can return null or undefined in addition to the value.

      • fallback: T

        The fallback value in the case that val is null or undefined.

      Returns Promise<T>

      This method returns val if it is not null or undefined, otherwise, the fallback is returned. If val is a promise and rejects, then fallback is also returned.

    • Allows a value to be null or undefined and has a fallback.

      Type Parameters

      • T

        The type of value that is being checked.

      Parameters

      • val: ZObligatedValue<T>

        The value to check. This can be a promise that can return null or undefined in addition to the value.

      Returns Promise<T | null>

      This method returns val if it is not null or undefined, otherwise, null is returned. If val is a promise and rejects, then null is also returned.