包详细信息

@bemoje/type-of

bemoje85MIT不推荐使用1.0.4

Package is not maintained.

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

returns, string, representing, value's

自述文件

@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