Class CborMapDecodedStream

A ReadableStream that wraps the decoded CBOR "Map". RFC 8949 - Concise Binary Object Representation (CBOR)

Instances of this class is created from CborSequenceDecoderStream. This class is not designed for you to create instances of it yourself. It is merely a way for you to validate the type being returned.

import { assert, assertEquals } from "@std/assert";
import {
CborMapDecodedStream,
CborMapEncoderStream,
CborSequenceDecoderStream,
} from "@std/cbor";

const rawMessage: Record<string, number> = {
a: 0,
b: 1,
c: 2,
d: 3,
};

for await (
const value of ReadableStream.from(Object.entries(rawMessage))
.pipeThrough(new CborMapEncoderStream)
.pipeThrough(new CborSequenceDecoderStream())
) {
assert(value instanceof CborMapDecodedStream);
for await (const [k, v] of value) {
assertEquals(rawMessage[k], v);
}
}
Hierarchy

Constructors

Properties

Methods

Constructors

Properties

locked: boolean

Methods

  • Parameters

    • Optionalreason: any

    Returns Promise<void>

  • Parameters

    • options: {
          mode: "byob";
      }
      • mode: "byob"

    Returns ReadableStreamBYOBReader

  • Returns ReadableStreamDefaultReader<CborMapStreamOutput>

  • Parameters

    • Optionaloptions: ReadableStreamGetReaderOptions

    Returns ReadableStreamReader<CborMapStreamOutput>

  • Type Parameters

    • T

    Parameters

    Returns ReadableStream<T>

  • Parameters

    Returns Promise<void>