-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Lexus Drumgold <[email protected]>
- Loading branch information
1 parent
28301fb
commit 2f6588c
Showing
4 changed files
with
47 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* @file Type Tests - isInt | ||
* @module tutils/guards/tests/unit-d/isInt | ||
*/ | ||
|
||
import type testSubject from '../is-int' | ||
|
||
describe('unit-d:guards/isInt', () => { | ||
it('should guard number', () => { | ||
expectTypeOf<typeof testSubject>().guards.toBeNumber() | ||
}) | ||
}) |
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,16 @@ | ||
/** | ||
* @file Unit Tests - isInt | ||
* @module tutils/guards/tests/unit/isInt | ||
*/ | ||
|
||
import testSubject from '../is-int' | ||
|
||
describe('unit:guards/isInt', () => { | ||
it('should return false if value is not an integer', () => { | ||
expect(testSubject(faker.number.float({ min: 0.13 }))).to.be.false | ||
}) | ||
|
||
it('should return true if value is an integer', () => { | ||
expect(testSubject(faker.number.int())).to.be.true | ||
}) | ||
}) |
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
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,18 @@ | ||
/** | ||
* @file Type Guards - isInt | ||
* @module tutils/guards/isInt | ||
*/ | ||
|
||
import isNumber from './is-number' | ||
|
||
/** | ||
* Checks if the given `value` is an integer. | ||
* | ||
* @param {unknown} value - Value to evaluate | ||
* @return {value is number} `true` if `value` is an integer | ||
*/ | ||
const isInt = (value: unknown): value is number => { | ||
return isNumber(value) && value % 1 === 0 | ||
} | ||
|
||
export default isInt |