@kxtxr/ts-guard
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

@kxtxr/ts-guard

@kxtxr/ts-guard is a TypeScript utility package that provides a set of commonly used guard functions.

Installation

Install @kxtxr/ts-guard via npm:

npm install @kxtxr/ts-guard

Usage

Here is how you can use some of the guard functions:

import { isPresent, isNumber } from '@kxtxr/ts-guard';

const x: number | undefined | number | string = foo.bar;

if (isNumber(x)) {
  // x is number
}

if (isPresent(x)) {
  // x is number or string
}

Package Sidebar

Install

npm i @kxtxr/ts-guard

Weekly Downloads

6

Version

1.0.2

License

MIT

Unpacked Size

6.85 kB

Total Files

32

Last publish

Collaborators

  • kxtxr