https://github.com/a1exevs/ts-guards
Typescript guards
https://github.com/a1exevs/ts-guards
type-guards types typescript
Last synced: 11 months ago
JSON representation
Typescript guards
- Host: GitHub
- URL: https://github.com/a1exevs/ts-guards
- Owner: a1exevs
- License: mit
- Created: 2024-12-22T08:09:39.000Z (over 1 year ago)
- Default Branch: develop
- Last Pushed: 2025-07-21T19:12:13.000Z (11 months ago)
- Last Synced: 2025-07-21T21:28:55.994Z (11 months ago)
- Topics: type-guards, types, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@alexevs/ts-guards
- Size: 1.57 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# Description
Typescript guards
- Install the [npm package @alexevs/ts-guards](https://www.npmjs.com/package/@alexevs/ts-guards)
```bash
// with npm
npm i @alexevs/ts-guards
// with yarn
yarn add @alexevs/ts-guards
```
- Use the package
```typescript
import {
isNull,
isUndefined,
isNil,
isEmpty
} from '@alexevs/ts-guards';
console.log(isNull(null)); // true
console.log(isUndefined(undefined)); // true
console.log(isNil(null)); // true
console.log(isNil(undefined)); // true
console.log(isEmpty(undefined)); // true
console.log(isEmpty(null)); // true
console.log(isEmpty(false)); // false
console.log(isEmpty(true)); // false
console.log(isEmpty(0)); // false
console.log(isEmpty(1)); // false
console.log(isEmpty('')); // true
console.log(isEmpty('str')); // false
console.log(isEmpty([])); // true
console.log(isEmpty([1, 2, 3])); // false
console.log(isEmpty({})); // true
console.log(isEmpty({ name: 'Alex' })); // false
```
## Why?
Enhance your TypeScript projects with @alexevs/ts-guards!
This library provides a robust set of utility functions to simplify and streamline type-checking and guard validation in your code.
With ts-guards, you can ensure safer and readable type validation,
improving code reliability and reducing potential errors.