Operators
Comparison operators
Operators used to perform comparison operations.
$cmp
Compares two values and returns:
- -1 if the first value is less than the second.
- 1 if the first value is greater than the second.
- 0 if the two values are equivalent.
{ "$cmp": ["number", "number"] }
expry({ $cmp: [3, 5] }); // -1
expry({ $cmp: [5, 3] }); // 1
expry({ $cmp: [5, 5] }); // 0
$eq
Compares two values and returns:
- true when the values are equivalent.
- false when the values are not equivalent.
{ "$eq": ["any", "any"] }
expry({ $eq: [5, 5] }); // true
expry({ $eq: ["hello", "bye"] }); // false
$gt
Compares two values and returns:
- true when the first value is greater than the second value.
- false when the first value is less than or equivalent to the second value.
{ "$gt": ["number", "number"] }
expry({ $gt: [5, 2] }); // true
expry({ $gt: [5, 7] }); // false
$gte
Compares two values and returns:
- true when the first value is greater than or equivalent to the second value.
- false when the first value is less than the second value.
{ "$gte": ["number", "number"] }
expry({ $gte: [5, 2] }); // true
expry({ $gte: [5, 5] }); // true
expry({ $gte: [5, 7] }); // false
$lt
Compares two values and returns:
- true when the first value is less than the second value.
- false when the first value is greater than or equivalent to the second value.
{ "$lt": ["number", "number"] }
expry({ $lt: [5, 7] }); // true
expry({ $lt: [5, 2] }); // false
$lte
Compares two values and returns:
- true when the first value is less than or equivalent to the second value.
- false when the first value is greater than the second value.
{ "$lte": ["number", "number"] }
expry({ $lte: [5, 7] }); // true
expry({ $lte: [5, 5] }); // true
expry({ $lte: [5, 2] }); // false
$ne
Compares two values and returns:
- true when the values are not equivalent.
- false when the values are equivalent.
{ "$ne": ["any", "any"] }
expry({ $ne: ["hello", "bye"] }); // true
expry({ $ne: [5, 5] }); // false