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

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.22latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.22
1.0.10
1.0.00
0.0.90
0.0.80
0.0.70
0.0.60
0.0.50
0.0.40
0.0.30
0.0.20
0.0.10

Package Sidebar

Install

npm i @kxtxr/ts-guard

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

6.85 kB

Total Files

32

Last publish

Collaborators

  • kxtxr