# simple-is

> maximally minimal type-testing library

Latest version **0.2.0** (published 2013-04-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install simple-is
pnpm add simple-is
yarn add simple-is
bun add simple-is
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2013-04-21 |
| First published | 2013-04-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Olov Lassus |
| Maintainers | olov |
| Keywords | is, type, test, check, assert |

## Links

- npm: https://www.npmjs.com/package/simple-is
- Repository: https://github.com/olov/simple-is
- npm.io page: https://npm.io/package/simple-is

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 0.2.0 (latest) — 2013-04-21
- 0.1.0 — 2013-04-19

## README

# simple-is.js
A maximally minimal type-testing library. Use it to make your code
more readable. Works in node and browsers.



## Usage
`var is = require("simple-is");`

Use `is.number(x)` instead of `typeof x === "number"` (also `is.boolean`, `is.string`, `is.fn`).

Use `is.nan(x)` instead of `typeof x === "number" && isNaN(x)`, `x !== x` or ES6 `Number.isNaN(x)`.

Use `is.object(x)` instead of `x !== null && typeof x === "object"`.

Use `is.primitive(x)` instead of `x === null || x === undefined || typeof x === "boolean" || typeof x === "number" || typeof x === "string"` (verbose on purpose).

Use `is.array(x)` instead of ES5 `Array.isArray`.

Use `is.finitenumber(x)` instead of `typeof x === "number" && isFinite(x)` or ES6 `Number.isFinite(x)`.

Use `is.someof(x, ["first", 2, obj])` instead of (usually) `x === "first" || x === 2 || x === obj` or (alternatively)  `["first", 2, obj].indexOf(x) >= 0`. Great for reducing copy and paste mistake in `if`-conditions and for making them more readable.

Use `is.noneof(x, ["first", 2, obj])` instead of (usually) `x !== "first" && x !== 2 && x !== obj` or (alternatively)  `["first", 2, obj].indexOf(x) === -1`.

Use `is.own(x, "name")` instead of `Object.prototype.hasOwnProperty.call(x, "name")`.

That's it.



## Installation

### Node
Install using npm

    npm install simple-is

```javascript
var is = require("simple-is");
```

### Browser
Clone the repo and include it in a script tag

    git clone https://github.com/olov/simple-is.git

```html
<script src="simple-is/simple-is.js"></script>
```

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