Constructor
# new Comparator(callbackopt)
create new comparator
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
Monster.Util~exampleCallback |
<optional> |
Comparator callback |
- Since:
- 1.3.0
Example
import {Comparator} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.23.0/dist/modules/util/comparator.js';
console.log(new Comparator().lessThanOrEqual(2, 5))
// ↦ true
console.log(new Comparator().greaterThan(4, 2))
// ↦ true
console.log(new Comparator().equal(4, 4))
// ↦ true
console.log(new Comparator().equal(4, 5))
// ↦ false
Methods
# compare(a, b) → {integer}
Parameters:
Name | Type | Description |
---|---|---|
a |
* | |
b |
* |
Returns:
-1, 0 or 1
- Type
- integer
# equal(a, b) → {boolean}
Checks if two variables are equal.
Parameters:
Name | Type | Description |
---|---|---|
a |
* | |
b |
* |
Returns:
- Type
- boolean
# greaterThan(a, b) → {boolean}
Checks if variable a
is greater than b
Parameters:
Name | Type | Description |
---|---|---|
a |
* | |
b |
* |
Returns:
- Type
- boolean
# greaterThanOrEqual(a, b) → {boolean}
Checks if variable a
is greater than or equal to b
Parameters:
Name | Type | Description |
---|---|---|
a |
* | |
b |
* |
Returns:
- Type
- boolean
# lessThan(a, b) → {boolean}
Checks if variable a is less than b
Parameters:
Name | Type | Description |
---|---|---|
a |
* | |
b |
* |
Returns:
- Type
- boolean
# lessThanOrEqual(a, b) → {boolean}
Checks if variable a
is less than or equal to b
Parameters:
Name | Type | Description |
---|---|---|
a |
* | |
b |
* |
Returns:
- Type
- boolean
# reverse() → {Comparator}
changes the order of the operators
Returns:
- Type
- Comparator