@blockchaincommons/dcbor-parse - v1.0.0-beta.3
    Preparing search index...

    Type Alias Token

    Token: { span: Span } & (
        | { type: "Bool"; value: boolean }
        | { type: "BraceOpen" }
        | { type: "BraceClose" }
        | { type: "BracketOpen" }
        | { type: "BracketClose" }
        | { type: "ParenthesisOpen" }
        | { type: "ParenthesisClose" }
        | { type: "Colon" }
        | { type: "Comma" }
        | { type: "Null" }
        | { type: "NaN" }
        | { type: "Infinity" }
        | { type: "NegInfinity" }
        | {
            type: "ByteStringHex";
            value: DcborResult<Uint8Array, DcborParseError>;
        }
        | {
            type: "ByteStringBase64";
            value: DcborResult<Uint8Array, DcborParseError>;
        }
        | { type: "DateLiteral"; value: DcborResult<CborDate, DcborParseError> }
        | { type: "Number"; value: number }
        | { type: "String"; value: string }
        | {
            type: "TagValue";
            value: DcborResult<number | bigint, DcborParseError>;
        }
        | { type: "TagName"; value: string }
        | {
            type: "KnownValueNumber";
            value: DcborResult<number | bigint, DcborParseError>;
        }
        | { type: "KnownValueName"; value: string }
        | { type: "Unit" }
        | { type: "UR"; value: DcborResult<UR, DcborParseError> }
    )

    A token of the notation, with its span.

    The six literal kinds carry their decoded value or, when the text matched the literal's pattern but did not decode (an odd number of hex digits, a non-canonical base64 body, an impossible date, a tag or known-value number past 2⁶⁴ − 1, a UR the decoder rejects), the error the parser reports for it. TagValue and KnownValueNumber accept the full unsigned 64-bit range: a value that fits in Number.MAX_SAFE_INTEGER is a number, anything larger a bigint, so no precision is lost. A String token holds its source text, quotes included; escape sequences are kept as written.

    Type Declaration

    • Readonlyspan: Span

      Where the token sits in the source, in UTF-16 code units.

    • { type: "Bool"; value: boolean }
      • Readonlytype: "Bool"

        The discriminant.

      • Readonlyvalue: boolean

        true or false.

    • { type: "BraceOpen" }
      • Readonlytype: "BraceOpen"

        The discriminant.

    • { type: "BraceClose" }
      • Readonlytype: "BraceClose"

        The discriminant.

    • { type: "BracketOpen" }
      • Readonlytype: "BracketOpen"

        The discriminant.

    • { type: "BracketClose" }
      • Readonlytype: "BracketClose"

        The discriminant.

    • { type: "ParenthesisOpen" }
      • Readonlytype: "ParenthesisOpen"

        The discriminant.

    • { type: "ParenthesisClose" }
      • Readonlytype: "ParenthesisClose"

        The discriminant.

    • { type: "Colon" }
      • Readonlytype: "Colon"

        The discriminant.

    • { type: "Comma" }
      • Readonlytype: "Comma"

        The discriminant.

    • { type: "Null" }
      • Readonlytype: "Null"

        The discriminant.

    • { type: "NaN" }
      • Readonlytype: "NaN"

        The discriminant.

    • { type: "Infinity" }
      • Readonlytype: "Infinity"

        The discriminant.

    • { type: "NegInfinity" }
      • Readonlytype: "NegInfinity"

        The discriminant.

    • { type: "ByteStringHex"; value: DcborResult<Uint8Array, DcborParseError> }
      • Readonlytype: "ByteStringHex"

        The discriminant.

      • Readonlyvalue: DcborResult<Uint8Array, DcborParseError>

        The bytes, or InvalidHexString for an odd number of digits.

    • { type: "ByteStringBase64"; value: DcborResult<Uint8Array, DcborParseError> }
      • Readonlytype: "ByteStringBase64"

        The discriminant.

      • Readonlyvalue: DcborResult<Uint8Array, DcborParseError>

        The bytes, or InvalidBase64String for a body that is not canonical base64.

    • { type: "DateLiteral"; value: DcborResult<CborDate, DcborParseError> }
      • Readonlytype: "DateLiteral"

        The discriminant.

      • Readonlyvalue: DcborResult<CborDate, DcborParseError>

        The date, or InvalidDateString for text the date parser rejects.

    • { type: "Number"; value: number }
      • Readonlytype: "Number"

        The discriminant.

      • Readonlyvalue: number

        The number, as parseFloat reads it.

    • { type: "String"; value: string }
      • Readonlytype: "String"

        The discriminant.

      • Readonlyvalue: string

        The source text, quotes included; escapes as written.

    • { type: "TagValue"; value: DcborResult<number | bigint, DcborParseError> }
      • Readonlytype: "TagValue"

        The discriminant.

      • Readonlyvalue: DcborResult<number | bigint, DcborParseError>

        The tag number, or InvalidTagValue past 2⁶⁴ − 1.

    • { type: "TagName"; value: string }
      • Readonlytype: "TagName"

        The discriminant.

      • Readonlyvalue: string

        The name before the (.

    • {
          type: "KnownValueNumber";
          value: DcborResult<number | bigint, DcborParseError>;
      }
      • Readonlytype: "KnownValueNumber"

        The discriminant.

      • Readonlyvalue: DcborResult<number | bigint, DcborParseError>

        The known-value number, or InvalidKnownValue past 2⁶⁴ − 1.

    • { type: "KnownValueName"; value: string }
      • Readonlytype: "KnownValueName"

        The discriminant.

      • Readonlyvalue: string

        The name between the quotes; empty for ''.

    • { type: "Unit" }
      • Readonlytype: "Unit"

        The discriminant.

    • { type: "UR"; value: DcborResult<UR, DcborParseError> }
      • Readonlytype: "UR"

        The discriminant.

      • Readonlyvalue: DcborResult<UR, DcborParseError>

        The decoded UR, or InvalidUr for one the decoder rejects.