classify variable types with precision
yarn add @davalapar/vartype
const vartype = require('@davalapar/vartype');
vartype(value <Any>, strict? <Boolean>) : <String>
vartype(value);
null
,array
,object
number
,nan
,infinity
undefined
,boolean
,string
,bigint
,symbol
,function
vartype(value, true);
- everything in loose mode, plus:
integer
,float
,double
error
,date
,regexp
map
,set
,weakmap
,weakset
dataview
,arraybuffer
,sharedarraybuffer
- including typed arrays
int8array
,uint8array
,uint8clampedarray
int16array
,uint16array
,int32array
,uint32array
float32array
,float64array
,bigint64array
,biguint64array
- https://caniuse.com/#search=isInteger
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString#Using_toString_to_detect_object_class
- http://www.ecma-international.org/ecma-262/7.0/index.html#sec-object.prototype.tostring
MIT | @davalapar