# component-type

> Type assertions aka less-broken `typeof`

Latest version **2.0.0** (published 2023-11-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install component-type
pnpm add component-type
yarn add component-type
bun add component-type
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2023-11-16 |
| First published | 2014-01-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18 |
| Dependencies | 0 |
| Unpacked size | 4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 96 |
| Maintainers | timaschew, anthonyshort, ianstormtaylor, nami-doc, clintwood, trevorgerhardt, juliangruber, thehydroimpulse, dominicbarnes, dfcreative, mattmueller, tootallnate, yields, stephenmathieson, sindresorhus, tjholowaychuk, timoxley, jonathanong, jongleberry, maxogden, queckezz |
| Keywords | typeof, type, types, check, utility |

## Links

- npm: https://www.npmjs.com/package/component-type
- Repository: https://github.com/sindresorhus/component-type
- Homepage: https://github.com/sindresorhus/component-type#readme
- Issues: https://github.com/sindresorhus/component-type/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/component-type

## Recent versions

- 2.0.0 (latest) — 2023-11-16
- 1.2.2 — 2023-11-16
- 1.2.1 — 2016-03-15
- 1.2.0 — 2015-09-16
- 1.1.0 — 2014-12-08
- 1.0.0 — 2014-01-06

## README

# component-type

> Type assertions aka less-broken `typeof`

## Install

```sh
npm install component-type
```

## Usage

```js
import type from 'component-type';

const date = new Date();

console.log(type(date));
//=> 'date'
```

## API

```js
type(new Date) === 'date'
type({}) === 'object'
type(null) === 'null'
type(undefined) === 'undefined'
type('hey') === 'string'
type(true) === 'boolean'
type(false) === 'boolean'
type(12) === 'number'
type(type) === 'function'
type(/asdf/) === 'regexp'
type((function(){ return arguments })()) === 'arguments'
type([]) === 'array'
type(document.createElement('div')) === 'element'
type(NaN) === 'nan'
type(new Error('Oh noes')) === 'error'
type(new Buffer) === 'buffer'
```

It makes no guarantees about the correctness when fed untrusted user-input.

---
_Source: https://npm.io/package/component-type · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
