Skip to content

Commit

Permalink
chore: add description to isObject
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Jul 8, 2024
1 parent 56d9fff commit 25debc0
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/typed/isObject.ts
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]')
}

0 comments on commit 25debc0

Please sign in to comment.