Class Switch<Compare, Return>

An inline switch statement with cases and default

Type Parameters

  • Compare

  • Return

Hierarchy

  • Switch

Constructors

Properties

Methods

Constructors

  • Create the class

    Type Parameters

    • Compare

    • Return

    Parameters

    • compare: Compare

      The value to compare each case to

    Returns Switch<Compare, Return>

Properties

#cases: {
    compareTo: (() => Compare);
    valueIf: (() => Return);
}[] = []
#compare: Compare

Methods

  • Add a case to the switch statement

    Returns

    Parameters

    • compareTo: (() => Compare)

      Function to return the value to compare to

        • (): Compare
        • Returns Compare

    • valueIf: (() => Return)

      Function to return the return value if the comparison matches

        • (): Return
        • Returns Return

    Returns Switch<Compare, Return>

  • Get the final value of the switch statement

    Returns

    Parameters

    • valueIf: (() => Return)

      Function to return the return value if none of the cases matched

        • (): Return
        • Returns Return

    Returns Return

Generated using TypeDoc