Back to Explore

open-draft/outvariant

GitHub
2 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

  • The repository appears quiet and not actively maintained as of today (last upstream push and newest described update are from 2024-07-05, about 2 years ago).
  • Update cadence is irregular, with updates clustered in 2023-12 and 2024-07, and no evidence of further updates after 2024-07-05.

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