Skip to main content

decodeMap

export function decodeMap<TKey, TValue>(
  bytes: BytesLike,
  keyDecoder: Decoder<TKey>,
  valueDecoder: Decoder<TValue>
): [TKey, TValue][]

Decodes a CBOR encoded map. Calls a decoder function for each key-value pair (nothing is returned directly).

The decoder function is responsible for separating the key from the value, which are simply stored as consecutive CBOR elements.

Type parameters

TKey

TKey extends any

TValue

TValue extends any

Arguments

1. bytes

bytes: BytesLike

2. keyDecoder

keyDecoder: Decoder<TKey>

3. valueDecoder

valueDecoder: Decoder<TValue>

Returns

[TKey, TValue][]