Packages@accelint/predicates
isLesserEqual
Curried predicate that determines if a value is less than or equal to a threshold
Creates a predicate that determines if a value is less than or equal to a threshold.
Reference
function isLesserEqual<T extends number | string>(threshold: T): (value: T) => booleanExamples
import { isLesserEqual } from '@accelint/predicates';
const isAtMost100 = isLesserEqual(100);
isAtMost100(50); // true
isAtMost100(100); // true (inclusive)
isAtMost100(150); // false
// Age filtering
const ages = [16, 18, 21, 25, 30];
const underAge = ages.filter(isLesserEqual(20)); // [16, 18]Good to know: The threshold is inclusive. Use
isLesserfor exclusive comparison.
Related
- isLesser - Check if value is less than threshold (exclusive)
- isGreaterEqual - Check if value is greater than or equal to threshold
- isGreater - Check if value is greater than threshold
- isEqual - Check if value is equal to reference
- isNotEqual - Check if value is not equal to reference
- isBetween - Check if value is in a range (inclusive)