Back to Explore

open-draft/outvariant

GitHub
1 watchersOpen source

Last release:

outvariant is a TypeScript helper that provides an invariant assertion, it throws an error when a predicate is false. It’s useful for runtime checks while also narrowing types so values become non-nullable after the invariant call, and it supports formatted error messages with positional arguments (for example %s, %d/%i, %j, %o).

Project status

  • Active maintenance: The GitHub activity shows the most recent upstream push and reported updates occurred on 2024-07-05, and there have been no further update entries since then, so the source appears quiet/dormant (not actively maintained) as of 2026-06-09.
  • Update cadence: The visible updates cluster in 2023-12 to 2024-07 (v1.4.0 in 2023-03, v1.4.1 and v1.4.2 in 2023-12, v1.4.3 in 2024-07), after which the gap to today is about 22 to 23 months.

AI summary generated

AI-generated from public sources. May be inaccurate. Report

Recent updates

  • v1.4.3

    v1.4.3 contains a targeted bug fix for invariant.as polymorphic errors when formatting messages with multiple positional arguments. The change ensures the sprintf-style formatter receives each positional value as an individual argument rather than as a single array.

  • v1.4.2

    v1.4.2 is a small bug fix release focused on how `invariant.as` constructs the thrown error type. The code now prefers `Reflect.construct` with a fallback to calling the provided error factory.

  • v1.4.1

    v1.4.1 adds support for a new positional formatting token, %i, for formatting digits. The library now recognizes %i in format strings and formats invalid digit inputs as NaN. The release notes only mention this formatting change, but the diff also includes CI/release tooling configuration updates and a sizable dependency lockfile churn.

    Features
  • v1.4.0

    v1.4.0 adds ESM compatibility to improve how the package can be imported and used in ECMAScript module environments. It also includes a fix to the predicate assertion behavior specifically for cases involving the "as" syntax.

    Features