UNPKG

2.6 kBTypeScriptView Raw
1/**
2 * Helper class to perform comparison operations over arbitrary values.
3 *
4 * ### Example ###
5 *
6 * ObjectComparator.compare(2, "GT", 1); // Result: true
7 * ObjectComparator.areEqual("A", "B"); // Result: false
8 */
9export declare class ObjectComparator {
10 /**
11 * Perform comparison operation over two arguments.
12 * The operation can be performed over values of any type.
13 *
14 * @param value1 the first argument to compare
15 * @param operation the comparison operation: "==" ("=", "EQ"), "!= " ("<>", "NE"); "<"/">" ("LT"/"GT"), "<="/">=" ("LE"/"GE"); "LIKE".
16 * @param value2 the second argument to compare
17 * @returns result of the comparison operation
18 */
19 static compare(value1: any, operation: string, value2: any): boolean;
20 /**
21 * Checks if two values are equal.
22 * The operation can be performed over values of any type.
23 *
24 * @param value1 the first value to compare
25 * @param value2 the second value to compare
26 * @returns true if values are equal and false otherwise
27 */
28 static areEqual(value1: any, value2: any): boolean;
29 /**
30 * Checks if two values are NOT equal
31 * The operation can be performed over values of any type.
32 *
33 * @param value1 the first value to compare
34 * @param value2 the second value to compare
35 * @returns true if values are NOT equal and false otherwise
36 */
37 static areNotEqual(value1: any, value2: any): boolean;
38 /**
39 * Checks if first value is less than the second one.
40 * The operation can be performed over numbers or strings.
41 *
42 * @param value1 the first value to compare
43 * @param value2 the second value to compare
44 * @returns true if the first value is less than second and false otherwise.
45 */
46 static isLess(value1: any, value2: any): boolean;
47 /**
48 * Checks if first value is greater than the second one.
49 * The operation can be performed over numbers or strings.
50 *
51 * @param value1 the first value to compare
52 * @param value2 the second value to compare
53 * @returns true if the first value is greater than second and false otherwise.
54 */
55 static isGreater(value1: any, value2: any): boolean;
56 /**
57 * Checks if string matches a regular expression
58 *
59 * @param value a string value to match
60 * @param regexp a regular expression string
61 * @returns true if the value matches regular expression and false otherwise.
62 */
63 static match(value: any, regexp: any): boolean;
64}