@libraz/libcantus - v1.1.0
    Preparing search index...

    Function assertOneOf

    • Require a value to be one of a fixed set of names.

      TypeScript checks string-union options at compile time only, so a value that arrives from JSON, a config file, or a JavaScript caller reaches the engine unchecked and is then read against a table that has no entry for it — producing a silent undefined, a NaN velocity, or a crash far from the call.

      Type Parameters

      • const T extends string

      Parameters

      • value: unknown

        The value to check.

      • allowed: readonly T[]

        Every accepted name.

      • name: string

        What the value is, for the error message.

      Returns T

      The value, narrowed to the allowed union.

      If the value is not one of allowed. The message names the value by its type unless it is a string, and echoes at most the head of that string, so building it cannot itself fail on a circular object and cannot grow with the size of what was pasted into the field.