Learn about our RFC process, Open RFC meetings & more.Join in the discussion! ¬Ľ

typeov

1.2.5¬†‚Äʬ†Public¬†‚Äʬ†Published

typeov Build Status

Version Downloads Deps DevDeps

Install (~1900 bytes)

npm install --save typeov
yarn add typeov

Usage

import { typeov } from 'typeov'
 
const a = []
 
if (typeov(a) === 'array') {
  // true => array
}
 
if (typeof(a) === 'array') {
  // false => object
}
var typeov = require('typeov').typeov
 
var b = Math.PI
 
if (typeov(b) === 'float') {
  // true
}
const jsonString = '[{"version":"1.2.3"}]'
const isJSON = typeov(jsonString) === 'json' // true

Possible return values

  • array
  • boolean
  • buffer
  • float
  • function
  • infinity
  • json
  • map
  • null
  • number
  • object
  • promise
  • regexp
  • set
  • stream
  • symbol
  • undefined
  • weakmap
  • weakset

Notes

Be mindful of what you're checking

> typeov(Symbol)
'function'
> typeov(Symbol())
'symbol'
> typeov(Promise)
'function'
> typeov(new Promise(() => {}))
'promise'
> typeov(Promise.resolve(true))
'promise'

License

License

Install

npm i typeov

DownloadsWeekly Downloads

213

Version

1.2.5

License

MIT

Unpacked Size

183 kB

Total Files

9

Last publish

Collaborators

  • avatar