# @dozerg/condition

> Preconditions utility for TypeScript and JavaScript.

Latest version **1.0.11** (published 2025-07-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install @dozerg/condition
pnpm add @dozerg/condition
yarn add @dozerg/condition
bun add @dozerg/condition
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.11 |
| Published | 2025-07-31 |
| First published | 2022-02-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 20.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Zhao DAI |
| Maintainers | wqqafnd |
| Keywords | precondition, condition, assert, isNonNull, assertNonNull |

## Links

- npm: https://www.npmjs.com/package/@dozerg/condition
- Repository: https://github.com/daidodo/condition
- Homepage: https://github.com/daidodo/condition#readme
- Issues: https://github.com/daidodo/condition/issues
- npm.io page: https://npm.io/package/@dozerg/condition

## Recent versions

- 1.0.11 (latest) — 2025-07-31
- 1.0.10 — 2024-12-21
- 1.0.9 — 2024-11-30
- 1.0.8 — 2024-04-05
- 1.0.7 — 2023-12-10
- 1.0.6 — 2023-12-01
- 1.0.5 — 2023-09-01
- 1.0.4 — 2023-03-29
- 1.0.3 — 2022-09-18
- 1.0.2 — 2022-09-18
- 1.0.1 — 2022-02-28
- 1.0.0 — 2022-02-27

## README

# Condition

[![npm](https://img.shields.io/npm/v/@dozerg/condition.svg)](https://www.npmjs.com/package/@dozerg/condition) ![Downloads](https://img.shields.io/npm/dm/@dozerg/condition.svg)
[![Build Status](https://github.com/daidodo/condition/actions/workflows/node.js.yml/badge.svg)](https://github.com/daidodo/condition/actions)

Utilities for preconditions and assertions for TypeScript and JavaScript.

## Install

```sh
npm i @dozerg/condition
```

## Usage

```ts
import { isNonNull, assertNonNull } from '@dozerg/condition';

function foo(p?: string) {
  assertNonNull(p);
  p.length; // OK, p is string
  // ...

  const a = [1, undefined, 2];   // a is (number | undefined)[]
  const b = a.filter(isNonNull); // b is [1, 2], i.e. number[]
  // ...
}
```

## APIs

- [assertIsBigint](docs/README.md#assertisbigint)
- [assertIsBoolean](docs/README.md#assertisboolean)
- [assertIsClass](docs/README.md#assertisclass)
- [assertIsNumber](docs/README.md#assertisnumber)
- [assertIsString](docs/README.md#assertisstring)
- [assertNonNull](docs/README.md#assertnonnull)
- [assertTrue](docs/README.md#asserttrue)
- [assertIsObject](docs/README.md#assertisobject)
- [isBigint](docs/README.md#isbigint)
- [isBoolean](docs/README.md#isboolean)
- [isClass](docs/README.md#isclass)
- [isNonNull](docs/README.md#isnonnull)
- [isNumber](docs/README.md#isnumber)
- [isString](docs/README.md#isstring)
- [isObject](docs/README.md#isobject)

## License

MIT © Zhao DAI <daidodo@gmail.com>

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