ts-util-is
TypeScript icon, indicating that this package has built-in type declarations

2.0.2 • Public • Published

NPM Version CI Dev Dependency Status codecov

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()
  • isNil()
  • isNumber()
  • isObject()
  • isPlainObject()
  • isRegExp()
  • isString()
  • isSymbol()
  • isUndefined()
  • isInstance()

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.2
    3,516
    • latest

Version History

Package Sidebar

Install

npm i ts-util-is

Weekly Downloads

25,844

Version

2.0.2

License

MIT

Unpacked Size

17.4 kB

Total Files

10

Last publish

Collaborators

  • justinlettau