5.0.1 • Published 2 years ago
@ekb1zh/type v5.0.1
Simple tool for getting data type
Install
npm i @ekb1zh/typeReason
You can't just find out the type of the null, array and object values in runtime. For these three values, the type is always object.
typeof null // => 'object'
typeof [] // => 'object'
typeof {} // => 'object'This little library solves this problem quickly and efficiently.
import { typeOf } from '@ekb1zh/type'
typeOf(null) // => 'null'
typeOf([]) // => 'array'
typeOf({}) // => 'object'Also you can use type Kind for type checking.
import { Kind } from '@ekb1zh/type'
const validValue: Kind = 'null' // ok
const invalidValue: Kind = 'bla-bla-bla' // errorThe complete list of types that this library defines
null
undefined
boolean
number
string
symbol
bigint
function
array
object