# @vitruvius-labs/ts-predicate

> TypeScript predicates library

Latest version **7.2.3** (published 2026-08-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install @vitruvius-labs/ts-predicate
pnpm add @vitruvius-labs/ts-predicate
yarn add @vitruvius-labs/ts-predicate
bun add @vitruvius-labs/ts-predicate
```

## Health

**Score 55/100 (C)** — status: active.

Positive: esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 7.2.3 |
| Published | 2026-08-18 |
| First published | 2024-02-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | >=18.0.0 |
| Dependencies | 0 |
| Unpacked size | 78.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | VitruviusLabs |
| Maintainers | smashingquasar |
| Keywords | assert, assertion, guard, predicate, strict, ts, type, type-guard, typeguard, typescript |

## Links

- npm: https://www.npmjs.com/package/@vitruvius-labs/ts-predicate
- Repository: https://github.com/VitruviusLabs/typescript
- Homepage: https://github.com/VitruviusLabs/typescript/tree/main/packages/ts-predicate#readme
- Issues: https://github.com/VitruviusLabs/typescript/issues
- npm.io page: https://npm.io/package/@vitruvius-labs/ts-predicate

## Alternatives

- [csv-to-markdown-table](https://npm.io/package/csv-to-markdown-table.md) — 47.0K weekly downloads
- [@sapphire/ratelimits](https://npm.io/package/@sapphire/ratelimits.md) — 4.4K weekly downloads
- [js-csvparser](https://npm.io/package/js-csvparser.md) — 2.0K weekly downloads
- [@adadapted/js-sdk](https://npm.io/package/@adadapted/js-sdk.md) — 251 weekly downloads
- [@grapecity/spread-sheets-sparklines](https://npm.io/package/@grapecity/spread-sheets-sparklines.md) — 103 weekly downloads

## Recent versions

- 7.2.3 (latest) — 2026-08-18
- 7.2.2 — 2026-07-27
- 7.2.1 — 2026-05-20
- 7.2.0 — 2026-04-06
- 7.1.0 — 2026-03-25
- 7.0.0 — 2025-11-25
- 6.2.0 — 2025-02-24
- 6.1.0 — 2025-01-05
- 6.0.0 — 2024-12-26
- 5.5.0 — 2024-12-12
- 5.4.1 — 2024-12-06
- 5.4.0 — 2024-12-04
- 5.3.0 — 2024-12-01
- 5.2.0 — 2024-06-06
- 5.1.0 — 2024-05-27
- … 10 more at https://npm.io/package/@vitruvius-labs/ts-predicate/versions

## README

# ts-predicate

## Philosophy

We want this lib to provide a strong foundation for your projects with tools that
follow the strictest standards.

1. This lib is entirely dependency free on purpose to avoid bitter surprises.
2. All the provided functions are "pure": deterministic, stateless, and side-effect free.
3. The code is tested exhaustively for maximum coverage by unit tests and mutation tests.

## Presentation

This lib is primarily about validating incoming data with the use
of the `isStructuredData()` functions. These functions enforce complete
validation of the data based on the expected type.

The type is the source of truth and the validation follow from the type, not the other way.

The lib also provide several functions to help both in building
`isStructuredData()` descriptor and to discriminate types in your own code.

Because `NaN` is usually an undesirable value, this lib assimilate `NaN` to a
nullish value along with `undefined` and `null`.

`JSON.stringify()` converts `NaN` into `null`.

## Getting started

Choose your favourite package manager.

```bash
pnpm add @vitruvius-labs/ts-predicate
```

```bash
yarn add @vitruvius-labs/ts-predicate
```

```bash
npm install @vitruvius-labs/ts-predicate
```

## Documentation

- [TypeAssertion](documentation/type-assertion.md)
- [TypeGuard](documentation/type-guard.md)
- [TypeHint](documentation/type-hint.md)
- [Classes](documentation/classes.md)
- [Helper](documentation/helper.md)

---
_Source: https://npm.io/package/@vitruvius-labs/ts-predicate · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
