Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Decoder

Provide a higher-level interface around Tokeniser, to enable the reading of complex values as represented in arrays/objects etc.

Hierarchy

  • Decoder

Index

Constructors

constructor

  • new Decoder(initial: Uint8Array | Tokeniser, offset?: undefined | number, length?: undefined | number): Decoder
  • Create a decoder

    Parameters

    • initial: Uint8Array | Tokeniser

      the Uint8Array or Tokeniser to read from

    • Optional offset: undefined | number

      if a Uint8Array is supplied as first argument, the optional offset from which to start reading. Ignored otherwise.

    • Optional length: undefined | number

      if a Uint8Array is supplied as first argument, the optional number of bytes to read. Ignored otherwise.

    Returns Decoder

Properties

Private Readonly tokeniser

tokeniser: Tokeniser

The tokeniser to extract values from

Methods

hasRemaining

  • hasRemaining(): boolean
  • Check if more tokens can be read from the tokeniser

    Returns boolean

    true if there are more tokens

nextValue

  • Return the next value, parsed recursively.

    If no tokens can be read, a read error will be thrown.

    throws

    an InvalidDataError if no value can be read

    Returns CBORValue

    the next value

nextValueExpecting

  • Return the next value, if its CBOR type is acceptable to cborTypePredicate

    parame

    cborTypePredicate a predicate that should return true if the CBOR type is acceptable, false otherwise.

    throws

    an InvalidDataError if no value can be read

    Parameters

    Returns CBORValue

    the next value

Copyright © 2025 DiffusionData Ltd. All Rights Reserved.