-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(numeric): adding numericGreaterThanEquals condition operator
- Loading branch information
1 parent
01384d0
commit 35ad211
Showing
4 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/conditionOperators/numeric/numericGreaterThanEquals.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
22
src/conditionOperators/numeric/numericGreaterThanEquals.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters