ComparePoint
ComparePoint
A ComparePoint
object compares numbers against each other. For example, is 6 greater than 3, or is 8 equal to 10.
Kind: global class
- ComparePoint
- new ComparePoint(operator, value)
- instance
- .operator
- .operator ⇒
string
- .value
- .value ⇒
number
- .isMatch(value) ⇒
boolean
- .toJSON() ⇒
Object
- .toString() ⇒
string
- static
- .isValidOperator(operator) ⇒
boolean
- .isValidOperator(operator) ⇒
new ComparePoint(operator, value)
Create a ComparePoint
instance.
Throws:
CompareOperatorError
operator is invalidRequiredArgumentError
operator and value are requiredTypeError
value must be numeric
Param | Type | Description |
---|---|---|
operator | string | The comparison operator (One of = , != , <> , < , > , <= , >= ) |
value | number | The value to compare to |
comparePoint.operator
Set the comparison operator.
Kind: instance property of ComparePoint
Throws:
- CompareOperatorError operator is invalid
Param | Type | Description |
---|---|---|
operator | string | One of = , != , <> , < , > , <= , >= |
string
comparePoint.operator ⇒ The comparison operator.
Kind: instance property of ComparePoint
comparePoint.value
Set the value.
Kind: instance property of ComparePoint
Throws:
TypeError
value must be numeric
Param | Type |
---|---|
value | number |
number
comparePoint.value ⇒ The comparison value
Kind: instance property of ComparePoint
boolean
comparePoint.isMatch(value) ⇒ Check whether value matches the compare point
Kind: instance method of ComparePoint
Returns: boolean
- true
if it is a match, false
otherwise
Param | Type | Description |
---|---|---|
value | number | The number to compare |
Object
comparePoint.toJSON() ⇒ Return an object for JSON serialising.
This is called automatically when JSON encoding the object.
Kind: instance method of ComparePoint
string
comparePoint.toString() ⇒ Return the String representation of the object.
This is called automatically when casting the object to a string.
Kind: instance method of ComparePoint
boolean
ComparePoint.isValidOperator(operator) ⇒ Check if the operator is valid.
Kind: static method of ComparePoint
Returns: boolean
- true
if the operator is valid, false
otherwise
Param | Type |
---|---|
operator | string |