-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
56d9fff
commit 25debc0
Showing
1 changed file
with
21 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 |
---|---|---|
@@ -1,5 +1,26 @@ | ||
import { isTagged } from 'radashi' | ||
|
||
/** | ||
* Returns true if `value` is a plain object, a class instance | ||
* (excluding built-in classes like Date/RegExp), or an | ||
* `Object.create(null)` result. Objects from [other realms][1] are | ||
* also supported. | ||
* | ||
* [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof#instanceof_and_multiple_realms | ||
* | ||
* ``` | ||
* isObject({}) // true | ||
* isObject(new Object()) // true | ||
* isObject(Object.create(null)) // true | ||
* isObject(new class {}) // true | ||
* | ||
* isObject([]) // false | ||
* isObject(/.+/g) // false | ||
* isObject(new Date()) // false | ||
* isObject(new Map()) // false | ||
* isObject(new Set()) // false | ||
* ``` | ||
*/ | ||
export function isObject(value: unknown): value is object { | ||
return isTagged(value, '[object Object]') | ||
} |