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

new ComparePoint(operator, value)

Create a ComparePoint instance.

Throws:

  • CompareOperatorError operator is invalid
  • RequiredArgumentError operator and value are required
  • TypeError value must be numeric
ParamTypeDescription
operatorstringThe comparison operator (One of =, !=, <>, <, >, <=, >=)
valuenumberThe value to compare to

comparePoint.operator

Set the comparison operator.

Kind: instance property of ComparePoint
Throws:

  • CompareOperatorError operator is invalid
ParamTypeDescription
operatorstringOne of =, !=, <>, <, >, <=, >=

comparePoint.operator ⇒ string

The comparison operator.

Kind: instance property of ComparePoint

comparePoint.value

Set the value.

Kind: instance property of ComparePoint
Throws:

  • TypeError value must be numeric
ParamType
valuenumber

comparePoint.value ⇒ number

The comparison value

Kind: instance property of ComparePoint

comparePoint.isMatch(value) ⇒ boolean

Check whether value matches the compare point

Kind: instance method of ComparePoint
Returns: boolean - true if it is a match, false otherwise

ParamTypeDescription
valuenumberThe number to compare

comparePoint.toJSON() ⇒ Object

Return an object for JSON serialising.

This is called automatically when JSON encoding the object.

Kind: instance method of ComparePoint

comparePoint.toString() ⇒ string

Return the String representation of the object.

This is called automatically when casting the object to a string.

Kind: instance method of ComparePoint

ComparePoint.isValidOperator(operator) ⇒ boolean

Check if the operator is valid.

Kind: static method of ComparePoint
Returns: boolean - true if the operator is valid, false otherwise

ParamType
operatorstring