Back to Explore

open-draft/outvariant

GitHub
1 watchersOpen source

Last release: 7/5/2024

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 GitHub source open-draft/outvariant appears to be actively maintained, with the most recent documented change on 2024-07-05 (v1.4.3).
  • Apparent update cadence is irregular, with updates in late 2023 (v1.4.1 and v1.4.2 on 2023-12-14) and a follow-up about 7 months later (v1.4.3 on 2024-07-05).

AI summary generated Today

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

Recent updates

  • v1.4.3

    7/5/2024

    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

    12/14/2023

    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

    12/14/2023

    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

    3/23/2023

    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