-
-
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
cf64ff4
commit 84650de
Showing
6 changed files
with
60 additions
and
19 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
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,13 @@ | ||
/** | ||
* @file Type Tests - isObjectAny | ||
* @module tutils/utils/tests/unit-d/isObjectAny | ||
*/ | ||
|
||
import type { ObjectAny } from '#src/types' | ||
import type testSubject from '../is-object-any' | ||
|
||
describe('unit-d:utils/isObjectAny', () => { | ||
it('should guard ObjectAny', () => { | ||
expectTypeOf<typeof testSubject>().guards.toEqualTypeOf<ObjectAny>() | ||
}) | ||
}) |
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,20 @@ | ||
/** | ||
* @file Unit Tests - isObjectAny | ||
* @module tutils/utils/tests/unit/isObjectAny | ||
*/ | ||
|
||
import testSubject from '../is-object-any' | ||
|
||
describe('unit:utils/isObjectAny', () => { | ||
it('should return false if value is not instance object or pojo', () => { | ||
expect(testSubject(faker.string.hexadecimal({ length: 24 }))).to.be.false | ||
}) | ||
|
||
it('should return true if value is instance object', () => { | ||
expect(testSubject(faker.date.anytime())).to.be.true | ||
}) | ||
|
||
it('should return true if value is pojo', () => { | ||
expect(testSubject({ email: faker.internet.email() })).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,24 @@ | ||
/** | ||
* @file Utilities - isObjectAny | ||
* @module tutils/utils/isObjectAny | ||
*/ | ||
|
||
import type { ObjectAny } from '#src/types' | ||
import isArray from './is-array' | ||
import isObject from './is-object' | ||
import isObjectPlain from './is-object-plain' | ||
|
||
/** | ||
* Checks if `value` is a non-null object that is not an array (e.g. instance | ||
* objects, pojos). | ||
* | ||
* @see {@linkcode ObjectAny} | ||
* | ||
* @param {unknown} value - Value to check | ||
* @return {value is ObjectAny} `true` if `value` is pojo or instance object | ||
*/ | ||
const isObjectAny = (value: unknown): value is ObjectAny => { | ||
return isObjectPlain(value) || (isObject(value) && !isArray(value)) | ||
} | ||
|
||
export default isObjectAny |