A stateful, forward-only reader for Concise Binary Object Representation (CBOR) encoded data.

Hierarchy

  • CborReader

Constructors

Properties

#cachedState: Serialization.CborReaderState = CborReaderState.Undefined
#currentFrame: StackFrame
#data: Uint8Array
#isTagContext: boolean = false
#nestedItems: StackFrame[] = ...
#offset: number = 0

Methods

  • Asserts that there are enough bytes remaining in the buffer to read the give amount of bytes.

    Parameters

    • bytesToRead: number

      The number of bytes to read.

    Returns void

  • Peeks a signed integer from the data stream.

    Returns

    An object with the signed int and the bytes read.

    Returns {
        bytesRead: number;
        signedInt: bigint;
    }

    • bytesRead: number
    • signedInt: bigint
  • Peeks an unsigned integer from the data stream.

    Returns

    An object with the unsigned int and the bytes read.

    Returns {
        bytesRead: number;
        unsignedInt: bigint;
    }

    • bytesRead: number
    • unsignedInt: bigint
  • Reads the contents of a indefinite length bytearray or text and returns all the chunks concatenated.

    Returns

    The concatenated array.

    Parameters

    Returns {
        encodingLength: number;
        val: Uint8Array;
    }

    • encodingLength: number
    • val: Uint8Array
  • Skips the next item in the current nested level

    Returns

    the depth after the node has been skipped.

    Parameters

    • initialDepth: number

      The starting depth.

    Returns number

  • Reads the next data item as a byte string (major type 2).

    Returns

    The decoded byte array.

    Remark: The method accepts indefinite length strings, which it concatenates to a single string.

    Returns Uint8Array

  • Reads the next data item as a CBOR negative integer representation (major type 1).

    Returns

    An unsigned integer denoting -1 minus the integer.

    Returns bigint

  • Reads the next data item as a byte string (major type 2).

    Returns

    The decoded byte array.

    Remark: The method accepts indefinite length strings, which it concatenates to a single string.

    Returns Uint8Array

  • Reads the next data item as a UTF-8 text string (major type 3).

    Returns

    The decoded string.

    Remark: The method accepts indefinite length strings, which it concatenates to a single string.

    Returns string

  • Reads the next CBOR data item, returning a subarray with the encoded value. For indefinite length encodings this includes the break byte.

    Returns

    A subarray with the encoded value as a contiguous region of memory.

    Returns Uint8Array

  • Reads the next data item as the start of a map (major type 5).

    Returns

    The number of key-value pairs in a definite-length map, or null if the map is indefinite-length.

    remark: Map contents are consumed as if they were arrays twice the length of the map's declared size.

    For example, a map of size 1 containing a key of type int with a value of type string must be consumed by successive calls to readInt32 and readTextString.

    Returns null | number

  • Reads the next data item as a UTF-8 text string (major type 3).

    Returns

    The decoded string.

    Remark: The method accepts indefinite length strings, which it concatenates to a single string.

    Returns string

  • Peeks the definite length for given data item.

    Returns

    An object with the definite length and the bytes read.

    Parameters

    • header: CborInitialByte

      The initial byte header.

    • data: Uint8Array

      The data stream.

    Returns {
        bytesRead: number;
        length: number;
    }

    • bytesRead: number
    • length: number
  • Asserts that there are enough bytes remaining in the buffer to read the give amount of bytes.

    Parameters

    • data: Uint8Array

      The array to read the bytes from.

    • bytesToRead: number

      The number of bytes to read.

    Returns void

Generated using TypeDoc