1.2.0 • Published 5 years ago
taap v1.2.0
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 taapImport 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
5 years ago
1.1.0
5 years ago
1.0.3
5 years ago
1.0.2
5 years ago
1.0.1
5 years ago
1.0.0
5 years ago
1.0.0-beta.10
5 years ago
1.0.0-beta.9
5 years ago
1.0.0-beta.8
5 years ago
1.0.0-beta.7
5 years ago
1.0.0-beta.6
5 years ago
1.0.0-beta.5
5 years ago
1.0.0-beta.4
5 years ago
1.0.0-beta.3
5 years ago
1.0.0-beta.2
5 years ago
1.0.0-beta.1
5 years ago