is-real-object
v1.0.2
Published
Returns `true` if a value is any type of object, but not an array. Browserify-ready.
Downloads
1,017
Readme
is-real-object
Returns
true
if a value is any type of object, but not an array. Browserify-ready.
Why?!
Yea, that's it! Yea, it's so simple as !isArray && isObject
. Because all of the others checks that given value is-object or is-plain-object, or even is-extendable and is-obj. And last two are absolutely the same things - returns true
if a value is any type of object, including array-ish values.
That being said, just it isn't okey for me to pass array value as options
object for example.
Install
npm i is-real-object --save
Usage
For more use-cases see the tests
const isRealObject = require('is-real-object')
returns true
isRealObject({})
isRealObject({foo: 'bar'})
isRealObject(function () {})
isRealObject(arguments)
isRealObject(/foo/)
isRealObject(new Error())
isRealObject(new TypeError())
isRealObject(new Boolean()) // it is object!
isRealObject(new Number()) // it is object!
isRealObject(new String()) // it is object!
isRealObject(new Object())
isRealObject(new Date())
isRealObject(new RegExp())
isRealObject(new RegExp('foo'))
isRealObject(new Function())
isRealObject(new Function('foo'))
isRealObject(Object.create(null))
isRealObject(Object.create({}))
isRealObject(Object.create({a: 'b'}))
isRealObject(Object(0))
isRealObject(Object(1))
isRealObject(Object(false))
isRealObject(Object(true))
isRealObject(Object('foo'))
returns false
isRealObject(new Array())
isRealObject(new Array(2))
isRealObject(Number(123))
isRealObject(String(123))
isRealObject(Boolean(true))
isRealObject(Boolean(false))
isRealObject(Boolean('foo'))
isRealObject(String())
isRealObject(String(123))
isRealObject(String('foo'))
isRealObject([])
isRealObject(['a'])
isRealObject('foo')
isRealObject(null))
isRealObject(undefined)
isRealObject(NaN)
isRealObject(123)
isRealObject(0)
isRealObject(false)
isRealObject(true)
isRealObject()
Related
- is-extendable: Returns true if a value is any of the object types: array, regexp, plain object, function or date. This is useful for determining if a value can be extended,… more
- is-obj: Check if a value is an object
- is-plain-obj: Check if a value is a plain object
- is-plain-object: Returns true if an object was created by the
Object
constructor. - isobject: Returns true if the value is an object and not an array or null.
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.