# @quenk/kindof

> Test whether a value is simillar to another.

Latest version **1.2.0** (published 2018-02-10) · Apache-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @quenk/kindof
pnpm add @quenk/kindof
yarn add @quenk/kindof
bun add @quenk/kindof
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2018-02-10 |
| First published | 2018-01-03 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Lasana Murray |
| Maintainers | metasansana |
| Keywords | kind |

## Links

- npm: https://www.npmjs.com/package/@quenk/kindof
- Repository: https://github.com/quenktechnologies/kindof
- Homepage: https://github.com/quenktechnologies/kindof#readme
- Issues: https://github.com/quenktechnologies/kindof/issues
- npm.io page: https://npm.io/package/@quenk/kindof

## Recent versions

- 1.2.0 (latest) — 2018-02-10
- 1.1.2 — 2018-01-03
- 1.1.1 — 2018-01-03
- 1.1.0 — 2018-01-03
- 1.0.2 — 2018-01-03
- 1.0.1 — 2018-01-03

## README

KindOf
=======

Provides a function that tests whether a value matches a given pattern.

## Installation

```sh

  npm install --save @quenk/kindof

```

## Usage

`kindOf` takes two parameters, the first is the value to test and the second the pattern.

```typescript

  import {kindOf} from '@quenk/kindof';

  class T {
  
    name: 'King T'

  }

  const t = new T();

  if(kindOf(1, 1))
    console.log('yes');

  if(kindOf(1, Number))
    console.log('yes');

  if(kindOf('one', 'one'))
    console.log('yes')

  if(kindOf('one', String))
    console.log('yes')

  if(kindOf(t, T))
    console.log('yes')

  if(kindOf(t, {name:String}))
    console.log('yes')

```

## Description

Currently pattern matches are carried out like this:

| Pattern   | Description   | Example  |
| --------- | ------------- | -------- |
| string  | Matches the string exactly. | kindOf('somestring', 'somestring') |
| number  | Matches the number exactly. | kindOf(1, 1) |
| boolean | Matches the boolean literal exactly. | kindOf(true, true); kindOf(false, false) |
| object  | Treated as a shape, each key is treated as a pattern. | kindOf({one:1, two:'two'}, {one:1, two:String}) |
| function| Treated as a constructor and results in an instanceof check. | kindOf(new Point(), Point) |
| String  | Matches any string value. | kindOf('foo', String) |
| Boolean | Matches any boolean value. | kindOf(false, Boolean) |
| Number  | Matches any number value. | kindOf(12, Number) |
| Array   | Matches an array regardless of content. | kindOf([12], Array) | 


# License

Apache-2.0 (c) Quenk Technologies Limited.

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