1.0.2 • Published 8 years ago
tiny-typeof v1.0.2
tiny-typeof
a small and robust typeof
implementation
compression | size |
---|---|
tiny-typeof.js | 998 B |
tiny-typeof.min.js | 788 B |
tiny-typeof.min.js.gz | 448 B |
Install
$ npm install tiny-typeof
Example
var t = require('tiny-typeof')
t(false)
> 'boolean'
t('a')
> 'string'
t(0)
> 'number'
t({})
> 'object'
t([])
> 'array'
t(function (){})
> 'function'
t(null)
> 'null'
t(void 0)
> 'undefined'
t(Number('-'))
> 'nan'
t(new Date)
> 'date'
t(/asdf/)
> 'regexp'
t(arguments)
> 'arguments'
t(new CustomType)
> 'customtype'
if (process.browser) {
t(document.createElement('div'))
> 'div'
t(document.querySelectorAll('*'))
> 'nodelist'
}