A zero dependency Typescript type checking library that coerces unknown values.
npm install taapTaap)A lightweight zero dependency Typescript type checking library that coerces unknown values. More concise and accurate than typeof checks or similar type checking methods.
#### Install dependency
``bash`
npm i taap
#### Import and use methods
`ts
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
`ts
import { isArray } from 'taap';
const maybeArray: unknown = [1, 2, 3];
if (isArray
// maybeArray is now of type: number[]`
maybeArray.filter((x) => x > 1);
}
Supports optional generic return type:
- isArray()
- isObject()
- isFunction()
Fixed return type:
- isString()
- isDate()
- isRegExp()
- isBoolean()
- isNumber()
- isBigInt()
- isNull()
- isUndefined()
Other: