@blockchaincommons/envelope - v1.0.0-beta.4
    Preparing search index...

    Class Parameter

    Represents a parameter identifier in an expression.

    In Gordian Envelope, a parameter appears as a predicate in an assertion on an expression envelope. The parameter identifies the name of the argument, and the object of the assertion is the argument value.

    Parameters can be identified in two ways:

    1. By a numeric ID (for well-known parameters) - Known variant
    2. By a string name (for application-specific parameters) - Named variant

    A known parameter's id is the reference's u64: value is a number when it is a safe integer and a bigint otherwise, valueBigInt is always exact. A parameter may carry the value envelope of its argument (paramValue), which the reference keeps in the expression envelope.

    When encoded in CBOR, parameters are tagged with #6.40007.

    Implements

    Index
    • get value(): number | bigint | undefined

      The numeric id of a known parameter (a number when safe, else a bigint); undefined for a named one.

      Returns number | bigint | undefined

    • get valueBigInt(): bigint | undefined

      The exact numeric id of a known parameter; undefined for a named one.

      Returns bigint | undefined

    • get name(): string

      Returns the display name of the parameter.

      For known parameters with a name, returns the name. For known parameters without a name, returns the numeric ID as a string. For named parameters, returns the name enclosed in quotes.

      Returns string

    • get namedName(): string | undefined

      Returns the raw name for named parameters, or undefined for known parameters.

      Returns string | undefined

    • get assignedName(): string | undefined

      Returns the assigned name if present (for known parameters only).

      Returns string | undefined

    • get codec(): CborCodec<Parameter>

      Tagged-CBOR codec. decode requires #6.40007(n): the tag is part of the type, as in the reference's TryFrom<CBOR>; use fromUntaggedCbor for the bare id. tags is named from the global tags store at each access, as the reference's cbor_tags() is.

      Returns CborCodec<Parameter>

    • A known parameter with a numeric id and an optional display name.

      Parameters

      • value: number | bigint
      • Optionalname: string

      Returns Parameter

      EnvelopeError InvalidParameter when value is not a non-negative safe integer number or a bigint in 0 ..= 2⁶⁴ − 1

    • The parameter tag (40007), named as the global tags store names it at the time.

      Returns Tag[]

    • The bare id: the unsigned integer of a known parameter, the text of a named one.

      Returns Cbor

    • #6.40007(id), the tag named as the global tags store names it.

      Returns Cbor

    • Decode #6.40007(id) (the reference's TryFrom<CBOR>).

      Parameters

      • cbor: Cbor

      Returns Parameter

      CborError (dcbor's, with a code) — WrongType for an untagged value, WrongTag for another tag (both tags named as the global tags store names them), Custom invalid parameter for a content that is neither an unsigned integer nor text

    • Decode the bare id — the content of tag 40007 (the reference's from_untagged_cbor): an unsigned integer is a known parameter, a text a named one.

      Parameters

      • cbor: Cbor

      Returns Parameter

      CborError Custom invalid parameter for anything else

    • The reference's Display: the assigned name or the number for a known parameter, the name in quotes for a named one (lhs, 77, "x"); a parameter that carries a value appends : value. The ❰…❱ form belongs to the format strings, where the format context prints it on both sides.

      Returns string