0.1.6 • Published 2 years ago

@js-utilities/typecheck v0.1.6

Weekly downloads
279
License
MIT
Repository
github
Last release
2 years ago

Type checking library

npm version Build Status

A set of super-simple type checkers. Each checker returns boolean value. Most checkers are typescript type predicates.

Installation

npm i -S @js-utilities/typecheck

Usage example

import { isCallable } from "@js-utilities/typecheck";

const a: unknown = global.value;

if (isCallable(a)) a();

Available checkers:

CheckerReturn type
isCallableboolean
isFunctionvalue is Function
isArrowFunctionboolean
isArray<T>value is T[]
isObject<T>value is T
isBooleanvalue is boolean
isUndefinedvalue is undefined
isNumbervalue is number
isStringvalue is string
isSymbolvalue is symbol
isNullvalue is null
isMap<T, U>value is Map<T, U>
isSet<T>value is Set<T>
isWeakSet<T>value is WeakSet<T>
isWeakMap<T, U>value is WeakMap<T, U>
isPromise<T>value is Promise<T>

License

MIT License