Skip to content

Commit

Permalink
feat(numeric): adding numericGreaterThanEquals condition operator
Browse files Browse the repository at this point in the history
  • Loading branch information
roggervalf committed Feb 25, 2021
1 parent 01384d0 commit 35ad211
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/conditionOperators/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {numericEquals} from './numeric/numericEquals';
import {numericGreaterThan} from './numeric/numericGreaterThan';
import {numericGreaterThanEquals} from './numeric/numericGreaterThanEquals';
import {numericLessThan} from './numeric/numericLessThan';
import {numericLessThanEquals} from './numeric/numericLessThanEquals';
import {numericNotEquals} from './numeric/numericNotEquals';
Expand All @@ -12,6 +13,7 @@ import {stringNotEqualsIgnoreCase} from './string/stringNotEqualsIgnoreCase';
export const operators: Record<string, unknown>={
numericEquals,
numericGreaterThan,
numericGreaterThanEquals,
numericLessThan,
numericLessThanEquals,
numericNotEquals,
Expand Down
15 changes: 15 additions & 0 deletions src/conditionOperators/numeric/numericGreaterThanEquals.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { numericGreaterThanEquals } from './numericGreaterThanEquals';

describe('numericGreaterThanEquals', () => {
it('returns true', () => {
expect(numericGreaterThanEquals(5, 5)).toBeTruthy;
expect(numericGreaterThanEquals(8.2, 2.2)).toBeTruthy;
expect(numericGreaterThanEquals(Number.MAX_SAFE_INTEGER, Number.MIN_SAFE_INTEGER)).toBeTruthy;
});

it('returns false', () => {
expect(numericGreaterThanEquals(5, 7)).toBeFalsy;
expect(numericGreaterThanEquals(-2, -1)).toBeFalsy;
expect(numericGreaterThanEquals(Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER)).toBeFalsy;
});
});
22 changes: 22 additions & 0 deletions src/conditionOperators/numeric/numericGreaterThanEquals.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Numeric greater than or equals matching.
*
* @since 4.6.0
* @category Numeric
* @param {number} data The value to be compared.
* @param {number} expected The expected value.
* @returns {boolean} Returns `true` if `value` is greater than or equals `expected value`.
* @example
* ```javascript
* numericGreaterThanEquals(5, 5)
* // => true
*
* numericGreaterThanEquals(4, 8)
* // => false
* ```
*/
export function numericGreaterThanEquals(data: number, expected: number): boolean {
return (
data >= expected
);
}
4 changes: 2 additions & 2 deletions src/conditionOperators/numeric/numericLessThanEquals.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* Numeric less than equals matching.
* Numeric less than or equals matching.
*
* @since 4.6.0
* @category Numeric
* @param {number} data The value to be compared.
* @param {number} expected The expected value.
* @returns {boolean} Returns `true` if `value` is less than equals `expected value`.
* @returns {boolean} Returns `true` if `value` is less than or equals `expected value`.
* @example
* ```javascript
* numericLessThanEquals(5, 5)
Expand Down

0 comments on commit 35ad211

Please sign in to comment.