@bemoje/type-of

1.0.4 • Public • Published

@bemoje/type-of

Returns a string representing a value's constructor's name property, except for 'NaN', infinite values, 'Infinity', 'Null' and 'Undefined'.

Version

NPM version

Travis CI

dependencies

Dependencies

dependencies

Stats

NPM downloads Forks

Donate

Buy Me A Beer donate button PayPal donate button

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
Returns

string

Package Sidebar

Install

npm i @bemoje/type-of

Weekly Downloads

4

Version

1.0.4

License

MIT

Unpacked Size

8.32 kB

Total Files

5

Last publish

Collaborators

  • bemoje