npm.io
3.0.1 • Published 5 months ago

@pacote/is-plain-object

Licence
MIT
Version
3.0.1
Deps
0
Size
13 kB
Vulns
0
Weekly
0
Stars
18

@pacote/is-plain-object

version minified minified + gzip

Checks whether the provided value is a plain JavaScript object.

Installation

yarn add @pacote/is-plain-object

Usage

import { isPlainObject } from '@pacote/is-plain-object'

// These return true:
isPlainObject({})
isPlainObject({ an: 'object' })

// All of these return false:
isPlainObject(undefined)
isPlainObject(null)
isPlainObject(false)
isPlainObject(true)
isPlainObject(NaN)
isPlainObject(Infinity)
isPlainObject(0)
isPlainObject('string')
isPlainObject([])
isPlainObject(new ArrayBuffer(0))
isPlainObject(new Date())
isPlainObject(new Map())
isPlainObject(new Promise())
isPlainObject(new Set())
isPlainObject(new WeakMap())
isPlainObject(new WeakSet())
isPlainObject(o: any): boolean

isPlainObject() takes a single value and checks whether it is a plain object. May be used as a type guard.

License

MIT Luís Rodrigues.

Keywords