# type-assertion

> Assert the type of a value.

Latest version **1.0.0** (published 2015-09-19) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2015-09-19 |
| First published | 2015-09-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Ellen Gummesson |
| Maintainers | gummesson |
| Keywords | assert, assertion, assertions, type, types |

## Links

- npm: https://www.npmjs.com/package/type-assertion
- Repository: https://github.com/gummesson/type-assertion
- Issues: https://github.com/gummesson/type-assertion/issues
- npm.io page: https://npm.io/package/type-assertion

## Dependencies (1)

- [obj-type](https://npm.io/package/obj-type.md) ^1.0.0

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2015-09-19

## README

# type-assertion

[![NPM version][npm-img]][npm-url]
[![License][license-img]][license-url]
[![Build status][travis-img]][travis-url]

Assert the type of a value.

## Installation

```
npm install type-assertion
```

## Usage

``` javascript
var assert = require('type-assertion')

assert({}, 'object')
assert([], 'object')  //=> TypeError: expected object
assert('ok', 'value')
assert('', 'value')   //=> TypeError: expected value
```

## API

### assert(value, expected)

Assert that `value` has the type of `expected` (aliased to `assert.type`).

## Why?

To provide a simple way to assert types with a small footprint. Node.js'
[assert](https://nodejs.org/api/assert.html) module is nice, but it's a bit too
big when it comes to using it on the front-end.

## License

[MIT][license-url]

[npm-img]: https://img.shields.io/npm/v/type-assertion.svg?style=flat-square
[npm-url]: https://npmjs.com/package/type-assertion
[license-img]: http://img.shields.io/npm/l/type-assertion.svg?style=flat-square
[license-url]: LICENSE
[travis-img]: https://img.shields.io/travis/gummesson/type-assertion.svg?style=flat-square
[travis-url]: https://travis-ci.org/gummesson/type-assertion

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