Exposes a method that compares two objects.

interface IComparer {
    Cast<T1, T2>(this: T2, type: TypeRef<T1>): T1;
    Compare(x: any, y: any): number;
    Compare(x: any, y: any): number;
    TryCast<T1, T2>(this: T2, type: TypeRef<T1>): null | T1;
}

Hierarchy (view full)

Methods

  • Casts this object to the specified type. Throws error on failure.

    Type Parameters

    • T1

      The target type of the cast.

    • T2

      The type of the object to cast.

    Parameters

    Returns T1

  • Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.

    Parameters

    • x: any

      The first object to compare.

    • y: any

      The second object to compare.

    Returns number

    A signed integer that indicates the relative values of x and y: - If less than 0, x is less than y. - If 0, x equals y. - If greater than 0, x is greater than y.

  • Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.

    Parameters

    • x: any

      The first object to compare.

    • y: any

      The second object to compare.

    Returns number

    A signed integer that indicates the relative values of x and y: - If less than 0, x is less than y. - If 0, x equals y. - If greater than 0, x is greater than y.

  • Casts this object to the specified type. Returns null on failure.

    Type Parameters

    • T1

      The target type of the cast.

    • T2

      The type of the object to cast.

    Parameters

    Returns null | T1