@ekb1zh/type
TypeScript icon, indicating that this package has built-in type declarations

5.0.1 • Public • Published

Simple tool for getting data type

Install

npm i @ekb1zh/type

Reason

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' // error

The complete list of types that this library defines

null
undefined
boolean
number
string
symbol
bigint
function
array
object

Package Sidebar

Install

npm i @ekb1zh/type

Weekly Downloads

1

Version

5.0.1

License

MIT

Unpacked Size

7.48 kB

Total Files

13

Last publish

Collaborators

  • ekb1zh