# safe-is-type-ts

> Use is-type safely with TypeScript

Latest version **1.0.0** (published 2019-07-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install safe-is-type-ts
pnpm add safe-is-type-ts
yarn add safe-is-type-ts
bun add safe-is-type-ts
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2019-07-16 |
| First published | 2019-07-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 10.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 15 |
| Author | kgtkr |
| Maintainers | kgtkr |

## Links

- npm: https://www.npmjs.com/package/safe-is-type-ts
- Repository: https://github.com/kgtkr/safe-is-type-ts
- Homepage: https://github.com/kgtkr/safe-is-type-ts#readme
- Issues: https://github.com/kgtkr/safe-is-type-ts/issues
- npm.io page: https://npm.io/package/safe-is-type-ts

## Recent versions

- 1.0.0 (latest) — 2019-07-16

## README

# safe-is-type-ts

[![Build Status](https://travis-ci.org/kgtkr/safe-is-type-ts.svg?branch=master)](https://travis-ci.org/kgtkr/safe-is-type-ts)

## Install

```sh
$ npm i safe-is-type-ts
```

## Usage

```ts
import { isType, isNotType, toIsTypeFunction } from "safe-is-type-ts";

// isString: (x: unknown) => x is string
const isString = toIsTypeFunction((x: unknown) =>
    typeof x === "string" ? isType(x) : isNotType()
);

isString("x"); // true
isString(null); // false

// isA: (x: "a" | "b") => x is "a"
const isA = toIsTypeFunction((x: "a" | "b") =>
    x === "a" ? isType(x) : isNotType()
);

isA("a"); // true
isA("b"); // false
isA("c"); // Argument of type '"c"' is not assignable to parameter of type '"a" | "b"'
```

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