Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@conjurelabs/get-type

ConjureLabs3MIT1.0.0

returns the 'type' of a single value

javascript, typeof

readme

get-type

npm i @conjurelabs/get-type

Usage

returns the 'type' of a single value

getType({}) // 'object'
getType([]) // 'array'
getType('') // 'string'
getType(12) // 'number'
getType(5n) // 'bigint'
getType(new Date()) // 'date'
getType(new Error()) // 'error'

gotchyas:

  • only basic arrays will return 'array' - Int8Array and others will return 'object'
  • anything not determined will return 'object'
  • this does not differentiate between things like functions and async functions
  • set up for Node, tested on v12 - not set up for browsers