# alexreardon/tiny-invariant

A tiny invariant function

Repository: https://github.com/alexreardon/tiny-invariant
Canonical: https://ross.abutalabs.com/products/tiny-invariant
Language: TypeScript
License: MIT
License Family: permissive
Topics: assert, assertion, invariant, type-guard
Last push: 2024-07-25T02:22:37+00:00

## Health v2 (maintenance only)
Score: 23/100 (v2, computed 2026-09-03T02:39:23.370411+00:00)
- activity 0, release rhythm 8, longevity 100
- inputs: {"age_days": 3060, "days_push": 770, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1863, forks 48 (observed 2026-08-28T04:05:46.099507+00:00)

## What it is
A tiny, zero-dependency invariant assertion function for JavaScript and TypeScript that throws when a condition is falsy. It also narrows types in TypeScript and Flow, making it useful for runtime checks and type safety.

## Use cases
- assert a condition is truthy at runtime
- narrow nullable types in typescript
- replace the invariant package with a smaller alternative
- throw descriptive errors for invalid states
- validate function preconditions

## When to avoid
- you need sprintf-style message formatting from the original invariant package
- you need rich assertion APIs like chai or expect

## Facets
- artifact type: library
- maturity: stable
- function: error-handling, type-system
- domain: developer-tools, web-development, programming-languages
- platform: browser, cross-platform
- tags: assertion, invariant, type-guard, typescript, zero-dependency, tiny, nodejs

## Member repositories
- alexreardon/tiny-invariant (main) score 23

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:05:46.099507+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T03:15:38.273555+00:00, confidence not recorded.
  - readme: https://github.com/alexreardon/tiny-invariant (fetched 2026-08-28T04:05:46.099507+00:00, sha a06e464581f1)
  - registry_npm: https://registry.npmjs.org/tiny-invariant (fetched 2026-08-29T10:54:50.559832+00:00, sha 4e88b78ae15b)
- Data as of 2026-08-30T08:39:29.467469+00:00.
