Détail du package

ts-util-is

justinlettau17.7kMIT2.1.0

TypeScript typeof utility helper with no dependencies.

typescript, util, typeof, type guards

readme

NPM Version CI 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 string[]
}

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 string
}

Methods

  • isArray()
  • isBase64()
  • isBoolean()
  • isDate()
  • isDateValid()
  • isDefined()
  • isError()
  • isFunction()
  • isGuid()
  • isInfinity()
  • isNegativeNumber()
  • isNull()
  • isNil()
  • isNonEmptyString()
  • isNonZeroNumber()
  • isNumber()
  • isObject()
  • isPlainObject()
  • isPositiveNumber()
  • isRegExp()
  • isString()
  • isSymbol()
  • isUndefined()
  • isInstance()

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

2.1.0 (2024-05-07)

Features

  • Add isNegativeNumber, isPositiveNumber, and isNonZeroNumber (#67) (3133ab8)
  • add isNonEmptyString (#66) (59fa707)

2.0.2 (2023-06-26)

Bug Fixes

2.0.2 (2021-12-04)

Bug Fixes

2.0.1 (2021-10-28)

Bug Fixes

2.0.0 (2021-10-27)

⚠ BREAKING CHANGES

  • This package is now pure ESM

Features

1.3.1 (2021-08-31)

1.3.0 (2021-08-29)

Features

1.2.1 (2020-11-28)

Bug Fixes

1.2.0 (2020-11-28)

Features

  • add isNil and isInstance type guards (#20) (fd82f8b)

1.1.3 (2017-10-09)

1.1.2 (2017-07-18)

1.1.1 (2017-07-17)

1.1.0 (2017-07-05)

Features

  • add isPlainObject function (f8657a3)