@bemoje/type-of
v1.0.4
Published
Returns a string representing a value's constructor's name property, except for 'NaN', infinite values, 'Infinity', 'Null' and 'Undefined'.
Downloads
16
Maintainers
Readme
@bemoje/type-of
Returns a string representing a value's constructor's name property, except for 'NaN', infinite values, 'Infinity', 'Null' and 'Undefined'.
Version
Travis CI
Dependencies
Stats
Donate
Installation
npm install @bemoje/type-of
npm install --save @bemoje/type-of
npm install --save-dev @bemoje/type-of
Usage
import typeOf from '@bemoje/type-of'
typeOf(NaN)
//=> NaN
typeOf(Infinity)
//=> Infinity
typeOf(Number.POSITIVE_INFINITY)
//=> Infinity
typeOf(Number.NEGATIVE_INFINITY)
//=> Infinity
typeOf('asdf')
//=> 'String'
typeOf(new String('asdf'))
//=> 'String'
typeOf(1)
//=> 'Number'
typeOf(Number(1))
//=> 'Number'
typeOf(new Number(1))
//=> 'Number'
typeOf(new Object())
//=> 'Object'
typeOf({})
//=> 'Object'
typeOf([])
//=> 'Array'
class Custom {}
typeOf(new Custom())
//=> 'Custom'
typeOf(undefined)
//=> 'Undefined'
typeOf(null)
//=> 'Null'
Tests
Uses Jest to test module functionality. Run tests to get coverage details.
npm run test
API
typeOf
Returns
a string representing a value's constructor's name property, except for 'NaN', infinite values, 'Infinity', 'Null' and 'Undefined'.
Parameters
value
any The value to evaluate