cbor2
    Preparing search index...

    Class DecodeStream

    Decode bytes into a stream of events describing the CBOR read from the bytes. Currently requires a full single CBOR value, with no extra bytes in the input.

    Implements

    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    defaultOptions: Required<DecodeStreamOptions> = ...

    Methods

    • Get the stream of events describing the CBOR item. Yields Value tuples.

      Returns ValueGenerator

      On invalid input or extra data in input.

      const s = new DecodeStream(buffer);
      for (const [majorType, additionalInfo, value] of s) {
      ...
      }
    • Get a stream of events describing all CBOR items in the input CBOR Sequence consisting of multiple CBOR items. Yields Value tuples.

      Note that this includes items indicating the start of an array or map, and the end of an indefinite-length item, and tag numbers separate from the tag content. Does not guarantee that the input is valid.

      Will attempt to read all items in an array or map, even if indefinite. Throws when there is insufficient data to do so. The same applies when reading tagged items, byte strings and text strings.

      Returns ValueGenerator

      On insufficient data.

      const s = new DecodeStream(buffer);
      for (const [majorType, additionalInfo, value] of s.seq()) {
      ...
      }
    • Get the chunk of this stream from the given position to the current offset.

      Parameters

      • begin: number

        Position to read from. Should be <= current offset.

      Returns Uint8Array

      Subarray of input stream (not copy).