-
-
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 <unicornware@flexdevelopment.llc>
- Loading branch information
1 parent
469f4ac
commit 0690a24
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 - isDate | ||
* @module tutils/utils/tests/unit-d/isDate | ||
*/ | ||
|
||
import type testSubject from '../is-date' | ||
|
||
describe('unit-d:utils/isDate', () => { | ||
it('should guard Date', () => { | ||
expectTypeOf<typeof testSubject>().guards.toEqualTypeOf<Date>() | ||
}) | ||
}) |
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 - isDate | ||
* @module tutils/utils/tests/unit/isDate | ||
*/ | ||
|
||
import testSubject from '../is-date' | ||
|
||
describe('unit:utils/isDate', () => { | ||
it('should return false if value is not Date instance', () => { | ||
expect(testSubject(faker.date.anytime().toISOString())).to.be.false | ||
}) | ||
|
||
it('should return true if value is Date instance', () => { | ||
expect(testSubject(faker.date.anytime())).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 Utilities - isDate | ||
* @module tutils/utils/isDate | ||
*/ | ||
|
||
import isObject from './is-object' | ||
|
||
/** | ||
* Checks if `value` is a {@linkcode Date} instance. | ||
* | ||
* @param {unknown} value - Value to check | ||
* @return {value is Date} `true` if `value` is {@linkcode Date} instance | ||
*/ | ||
function isDate(value: unknown): value is Date { | ||
return isObject(value) && Reflect.get(value, 'constructor') === Date | ||
} | ||
|
||
export default isDate |