type-predicate-utils

A collection of predicate functions for checking variable types, written in TypeScript

Usage no npm install needed!

<script type="module">
  import typePredicateUtils from 'https://cdn.skypack.dev/type-predicate-utils';
</script>

README

type-predicate-utils

Build Status Coverage Status npm version

Description:

A collection of simple predicate functions, written in TypeScript, for checking variable types. JavaScript UMD and TypeScript declaration file will be generated when building the package.

Installation:

npm install type-predicate-utils

Usage:

import { 
    isString, 
    isBoolean, 
    isDefined, 
    isUndefined, 
    isNull, 
    isObject,
    isArray,
    isEmptyArray,
    isNonEmptyArray,
    isFunction
 } from 'type-predicate-utils';

...

isString('foo')       // true
isBoolean({})         // false
isDefined([])         // true
isUndefined({})       // false
isNull(null)          // true
isObject({})          // true
isArray([])           // true
isEmptyArray([])      // true
isNonEmptyArray([])   // false
isFunction(() => {})  // true