isLesser()
isLesser<
T
>(threshold
): (value
) =>boolean
Creates a predicate function that determines if a value is less 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 isBelowLimit = isLesser(100);
isBelowLimit(50); // true
isBelowLimit(150); // false
const isBeforeM = isLesser('M');
isBeforeM('A'); // true
isBeforeM('Z'); // false
// Useful with arrays
const temperatures = [15, 25, 35, 45];
const cool = temperatures.filter(isLesser(30)); // [15, 25]