Packages@accelint/predicates
isGreaterEqual
Curried predicate that determines if a value is greater than or equal to a threshold
Creates a predicate that determines if a value is greater than or equal to a threshold.
Reference
function isGreaterEqual<T extends number | string>(threshold: T): (value: T) => booleanExamples
import { isGreaterEqual } from '@accelint/predicates';
const isAtLeast18 = isGreaterEqual(18);
isAtLeast18(21); // true
isAtLeast18(18); // true (inclusive)
isAtLeast18(16); // false
// Passing grade filter
const scores = [45, 78, 92, 65, 88];
const passing = scores.filter(isGreaterEqual(70)); // [78, 92, 88]Combined Example: Range Validation
import { isGreaterEqual, isLesserEqual } from '@accelint/predicates';
import { andFn } from '@accelint/core';
// Create a range validator by composing predicates
const isBetween0And100 = andFn(
isGreaterEqual(0),
isLesserEqual(100)
);
isBetween0And100(50); // true
isBetween0And100(150); // false
isBetween0And100(-10); // falseGood to know: The threshold is inclusive. Use
isGreaterfor exclusive comparison.
Related
- isGreater - Check if value is greater than threshold (exclusive)
- isLesserEqual - Check if value is less than or equal to threshold
- isLesser - Check if value is less 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)