1.2.0 • Published 4 years ago

taap v1.2.0

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

Type Assertion And Predicate (Taap)

A lightweight zero dependency Typescript type checking library that coerces unknown values. More concise and accurate than typeof checks or similar type checking methods.

🛠 Getting Started

Install dependency

npm i taap

Import and use methods

import { isArray } from 'taap';

const maybeArray: unknown = [];

if (typeof maybeArray === 'array') {
  🚫 typeof [] === 'object'
} else if (isArray(maybeArray)) {
  // `maybeArray` is now of type: `any[]`
  ✅ maybeArray.push(1);
}

Optionally supply a return type

import { isArray } from 'taap';

const maybeArray: unknown = [1, 2, 3];

if (isArray<number>(maybeArray)) {
  // `maybeArray` is now of type: `number[]`
  maybeArray.filter((x) => x > 1);
}

🔭 Available Methods

📚Full documentation

Supports optional generic return type:

  • [isArray()](https://schuchard.github.io/taap/globals.html#isarray)
  • [isObject()](https://schuchard.github.io/taap/globals.html#isobject)
  • [isFunction()](https://schuchard.github.io/taap/globals.html#isfunction)

Fixed return type:

  • [isString()](https://schuchard.github.io/taap/globals.html#isstring)
  • [isDate()](https://schuchard.github.io/taap/globals.html#isdate)
  • [isRegExp()](https://schuchard.github.io/taap/globals.html#isregexp)
  • [isBoolean()](https://schuchard.github.io/taap/globals.html#isboolean)
  • [isNumber()](https://schuchard.github.io/taap/globals.html#isnumber)
  • [isBigInt()](https://schuchard.github.io/taap/globals.html#isbigint)
  • [isNull()](https://schuchard.github.io/taap/globals.html#isnull)
  • [isUndefined()](https://schuchard.github.io/taap/globals.html#isundefined)

Other:

  • [getType()](https://schuchard.github.io/taap/globals.html#gettype)
1.2.0

4 years ago

1.1.0

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

1.0.0-beta.10

4 years ago

1.0.0-beta.9

4 years ago

1.0.0-beta.8

4 years ago

1.0.0-beta.7

4 years ago

1.0.0-beta.6

4 years ago

1.0.0-beta.5

4 years ago

1.0.0-beta.4

4 years ago

1.0.0-beta.3

4 years ago

1.0.0-beta.2

4 years ago

1.0.0-beta.1

4 years ago