# @slimio/is

> SlimIO is (JavaScript Primitives &amp; Objects type checker)

Latest version **2.0.0** (published 2023-01-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install @slimio/is
pnpm add @slimio/is
yarn add @slimio/is
bun add @slimio/is
```

## 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 | 2.0.0 |
| Published | 2023-01-23 |
| First published | 2018-09-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=16 |
| Dependencies | 0 |
| Unpacked size | 14.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | SlimIO |
| Maintainers | fraxken, alexandre.malaj |
| Keywords | is, typecheck, check, checking, typeof, instanceof, validate, node, test, assert, assertion |

## Links

- npm: https://www.npmjs.com/package/@slimio/is
- Repository: https://github.com/SlimIO/is
- Homepage: https://github.com/SlimIO/is#readme
- Issues: https://github.com/SlimIO/is/issues
- npm.io page: https://npm.io/package/@slimio/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

- 2.0.0 (latest) — 2023-01-23
- 1.5.1 — 2019-06-11
- 1.5.0 — 2019-02-27
- 1.4.0 — 2018-12-02
- 1.3.0 — 2018-11-10
- 1.2.0 — 2018-10-18
- 1.1.0 — 2018-09-25
- 1.0.0 — 2018-09-22

## README

# SlimIO IS
![version](https://img.shields.io/badge/dynamic/json.svg?style=for-the-badge&url=https://raw.githubusercontent.com/SlimIO/is/master/package.json&query=$.version&label=Version)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg?style=for-the-badge)](https://github.com/SlimIO/is/commit-activity)
![MIT](https://img.shields.io/github/license/mashape/apistatus.svg?style=for-the-badge)
![size](https://img.shields.io/bundlephobia/min/@slimio/is.svg?style=for-the-badge)
![build](https://img.shields.io/github/actions/workflow/status/SlimIO/is/node.js.yml?style=for-the-badge)

Node.js JavaScript Type checker (Primitives, Objects, etc..)

Package heavily inspired by `@sindresorhus/is`. This package aims to work on Node.js (no browser support).

## Why

- Focus on type checking (no fancy feature).
- Focus on Node.js support.
- Come with a TypeScript definition (which works).
- Is concerned about being stable.

## Requirements
- [Node.js](https://nodejs.org/en/) v16 or higher.

## Getting Started

This package is available in the Node Package Repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).

```bash
$ npm i @slimio/is
# or
$ yarn add @slimio/is
```

## Usage example

```js
const { strictEqual } = require("assert");
const is = require("@slimio/is");

strictEqual(is.bool(true), true);
strictEqual(is.string("hello"), true);
strictEqual(is.map(new Map()), true);
strictEqual(is.func(() => {}), true);
```

The `is` const namespace is a Plain JavaScript Object with a lot of exported methods (check the below API Documentation).

## API

All methods can be called as follow: `is.{methodName}`. All methods return a `boolean` value.

### Primitives

| method | example |
| --- | --- |
| string | `is.string("hello")` |
| number | `is.number(10)` |
| boolean | `is.boolean(true)` |
| bool | `is.bool(false)` |
| symbol | `is.symbol(Symbol("foo"))` |
| undefined | `is.undefined(undefined)` |
| bigint | `is.bigint(50n)` |
| nullValue | `is.nullValue(null)` |
| nullOrUndefined | `is.nullOrUndefined(null)` |
| primitive | `is.primitive("hello")` |

> is.null is not available because of a name restriction.

### Objects

| method | example |
| --- | --- |
| promise | `is.promise(new Promise())` |
| classObject | `is.classObject(new Class{})` |
| array | `is.array([])` |
| object | `is.object({})` |
| plainObject | `is.plainObject(Object.create(null))` |
| set | `is.set(new Set())` |
| map | `is.map(new Map())` |
| weakMap | `is.weakMap(new WeakMap())` |
| weakSet | `is.weakSet(new WeakSet())` |
| error | `is.error(new Error("ooppss!"))` |
| date | `is.date(new Date())` |
| regExp | `is.regExp(/^hello world$/)` |
| buffer | `is.buffer(Buffer.from("hello"))` |

> is.class is not available because of a name restriction.

### Functions & Iterators

| method | example |
| --- | --- |
| func | `is.func(new Function())` |
| generatorFunction | N/A |
| asyncFunction | `is.asyncFunction(async function() {})` |
| boundFunction | `is.boundFunction((function(){}).bind(null))` |
| iterable | `is.iterable([1, 2])` |
| asyncIterable | N/A |
| generator | N/A |

> is.function has been reduced to is.func because of a name restriction.

### Typed Arrays

| method | example |
| --- | --- |
| typedArray | `is.typedArray(new int8Array())` |
| int8Array | `is.int8Array(new int8Array())` |
| uint8Array | `is.uint8Array(new uint8Array())` |
| uint8ClampedArray | `is.uint8ClampedArray(new uint8ClampedArray())` |
| int16Array | `is.int16Array(new int16Array())` |
| uint16Array | `is.uint16Array(new uint16Array())` |
| int32Array | `is.int32Array(new int32Array())` |
| uint32Array | `is.uint32Array(new uint32Array())` |
| float32Array | `is.float32Array(new float32Array())` |
| float64Array | `is.float64Array(new float64Array())` |
| arrayBuffer | `is.arrayBuffer(new ArrayBuffer())` |
| sharedArrayBuffer | `is.sharedArrayBuffer(new SharedArrayBuffer())` |
| dataView | `is.dataView(new DataView(new ArrayBuffer(8)))` |

### Misc

| method | example |
| --- | --- |
| nan | `is.nan(Number("booom!"))` |
| integer | `is.integer(5 / 10)` |
| directInstanceOf | `is.directInstanceOf(Object, {})` |
| truthy | `is.truthy(true)` |
| falsy | `is.falsy("")` |
| emptyString | `is.emptyString("")` |

## Dependencies

This project have no dependencies.

## License
MIT

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