isGreater()
isGreater<
T
>(threshold
): (value
) =>boolean
Creates a predicate function that determines if a value is greater than a threshold.
Type Parameters
T
T
extends string
| number
The type of the values (number or string)
Parameters
threshold
T
The threshold value to compare against
Returns
(
value
):boolean
Parameters
value
T
Returns
boolean
Remarks
- Pure function with no side effects
- Uses JavaScript's
>
operator for comparison - Works with both numbers and strings (lexicographic comparison for strings)
- Useful for array filtering and functional composition
Example
const isGreaterThan10 = isGreater(10);
isGreaterThan10(15); // true
isGreaterThan10(5); // false
const isAfterM = isGreater('M');
isAfterM('Z'); // true
isAfterM('A'); // false
// Useful with arrays
const numbers = [1, 5, 10, 15, 20];
const greaterThan10 = numbers.filter(isGreater(10)); // [15, 20]