@metreeca/core - v0.9.18
    Preparing search index...

    Function assert

    • Validates a value against a type guard and returns it.

      Applies the guard to the value: if it passes, returns the value; otherwise, throws a TypeError. When no custom message is provided, generates a descriptive message from the guard function name (e.g., isString produces "expected string").

      Type Parameters

      • T

      Parameters

      • value: unknown

        The value to validate

      • guard: Guard<T>

        The type guard function to apply

      • Optionalmessage: string

        Optional custom error message; defaults to a message derived from the guard function name

      Returns T

      The validated value

      When the guard returns false