@conjurelabs/get-type

1.0.0 • Public • Published

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

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i @conjurelabs/get-type

      Weekly Downloads

      1

      Version

      1.0.0

      License

      MIT

      Unpacked Size

      3.27 kB

      Total Files

      4

      Last publish

      Collaborators

      • tmarshall