Helpful
    Preparing search index...

    Function castEnum

    Attempts to cast the candidate to an enumeration value.

    The enumeration type.

    The candidate to cast to the enum type.

    The fallback to use in the case that candidate cannot represent the enumeration type.

    The candidate if candidate represents the enumeration type, or fallback in the case that it does not.

    • Attempts to cast the candidate to an enumeration value.

      Type Parameters

      • TEnum extends Record<string, string | number>

      Parameters

      • enumeration: TEnum

        The enumeration type.

      • candidate: unknown

        The candidate to cast to the enum type.

      Returns TEnum[keyof TEnum] | undefined

      The candidate if candidate represents the enumeration type, or undefined in the case that it does not.

    • Attempts to cast the candidate to an enumeration value.

      Type Parameters

      • TEnum extends Record<string, string | number>

      Parameters

      • enumeration: TEnum

        The enumeration type.

      • candidate: unknown

        The candidate to cast to the enum type.

      • fallback: TEnum[keyof TEnum]

        The fallback to use in the case that candidate cannot represent the enumeration type.

      Returns TEnum[keyof TEnum]

      The candidate if candidate represents the enumeration type, or fallback in the case that it does not.