isGreaterEqual()
isGreaterEqual<
T
>(threshold
): (value
) =>boolean
Creates a predicate function that determines if a value is greater than or equal to 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 isAtLeast18 = isGreaterEqual(18);
isAtLeast18(21); // true
isAtLeast18(18); // true (inclusive)
isAtLeast18(16); // false
const isAtLeastB = isGreaterEqual('B');
isAtLeastB('C'); // true
isAtLeastB('B'); // true
isAtLeastB('A'); // false
// Useful with arrays
const scores = [45, 78, 92, 65, 88];
const passing = scores.filter(isGreaterEqual(70)); // [78, 92, 88]