node package manager
Easy sharing. Manage teams and permissions with one click. Create a free org »

ts-util-is

NPM Version Build Status Dev Dependency Status

ts-util-is

TypeScript typeof utility helper with no dependencies. Provides type guards for all common types.

Installation

npm install ts-util-is

Usage

Import everything:

import * as util from 'ts-util-is';
 
const value: string | string[] = 'hey there';
 
if (util.isArray(value)) {
    console.log(value.split(' ')); // `value` is array type
}

Import only what you need:

import { isArray, isString } from 'ts-util-is';
 
const value: string | string[] = 'hello again';
 
if (isArray(value)) {
    console.log(value.split(' ')); // `value` is array type
}

Methods

  • isArray()
  • isBase64()
  • isBoolean()
  • isDate()
  • isDateValid()
  • isDefined()
  • isError()
  • isFunction()
  • isGuid()
  • isInfinity()
  • isNull()
  • isNumber()
  • isObject()
  • isPlainObject()
  • isRegExp()
  • isString()
  • isSymbol()
  • isUndefined()