1.0.2 • Published 8 years ago

tiny-typeof v1.0.2

Weekly downloads
10
License
MIT
Repository
github
Last release
8 years ago

tiny-typeof

a small and robust typeof implementation

Build status

compressionsize
tiny-typeof.js998 B
tiny-typeof.min.js788 B
tiny-typeof.min.js.gz448 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'
}

License

MIT