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

    Interface ToEnvelope

    A trait for types that can be encoded as a Gordian Envelope.

    This interface defines the contract for converting a value into an envelope. Types implementing this interface can be used directly with envelope construction functions without explicit conversion.

    There are numerous built-in implementations for common types including:

    • Primitive types (numbers, strings, booleans)
    • CBOR values
    • Cryptographic types (digests, keys, etc.)
    • Assertions
    • Other envelopes
    // String implements ToEnvelope
    const e1 = Envelope.from("Hello");

    // Numbers implement ToEnvelope
    const e2 = Envelope.from(42);

    // Using in envelope construction
    const envelope = Envelope.from("subject")
    .addAssertion("name", "Alice") // Uses ToEnvelope for both predicate and object
    .addAssertion("age", 30); // Uses ToEnvelope for the numeric object
    interface ToEnvelope {
        toEnvelope(): Envelope;
    }

    Implemented by

    Index
    • Converts this value into a Gordian Envelope.

      This is the core method of the interface, converting the implementing type into an envelope representation. Most implementations will convert the value to a leaf envelope containing the value.

      Returns Envelope

      A new envelope containing the value.