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

    Class Function

    Represents a function identifier in an expression.

    In Gordian Envelope, a function appears as the subject of an expression envelope, with its parameters as assertions on that envelope.

    Functions can be identified in two ways:

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

    A known function'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.

    When encoded in CBOR, functions are tagged with #6.40006.

    Implements

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

      The numeric id of a known function (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 function; undefined for a named one.

      Returns bigint | undefined

    • get name(): string

      Returns the display name of the function.

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

      Returns string

    • get namedName(): string | undefined

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

      Returns string | undefined

    • get assignedName(): string | undefined

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

      Returns string | undefined

    • get codec(): CborCodec<Function>

      Tagged-CBOR codec. decode requires #6.40006(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<Function>

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

      Parameters

      • value: number | bigint
      • Optionalname: string

      Returns Function

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

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

      Returns Tag[]

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

      Returns Cbor

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

      Returns Cbor

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

      Parameters

      • cbor: Cbor

      Returns Function

      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 function for a content that is neither an unsigned integer nor text

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

      Parameters

      • cbor: Cbor

      Returns Function

      CborError Custom invalid function for anything else

    • The reference's Display: the assigned name or the number for a known function, the name in quotes for a named one (add, 99, "greet"). The «…» form belongs to the format strings, where the format context prints it on both sides.

      Returns string