https://github.com/conjurelabs/get-type
returns the 'type' of a single value
https://github.com/conjurelabs/get-type
javascript objects typeof
Last synced: 9 months ago
JSON representation
returns the 'type' of a single value
- Host: GitHub
- URL: https://github.com/conjurelabs/get-type
- Owner: ConjureLabs
- License: mit
- Created: 2020-05-10T22:59:03.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-05-10T23:02:47.000Z (about 6 years ago)
- Last Synced: 2025-10-09T08:05:21.910Z (9 months ago)
- Topics: javascript, objects, typeof
- Language: JavaScript
- Size: 1.95 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# get-type
```sh
npm i @conjurelabs/get-type
```
## Usage
returns the 'type' of a single value
```js
const getType = require('@conjurelabs/get-type')
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