Class CborByteDecodedStream

A ReadableStream that wraps the decoded CBOR "Byte String". 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 { concat } from "@std/bytes";
import {
CborByteDecodedStream,
CborByteEncoderStream,
CborSequenceDecoderStream,
} from "@std/cbor";

const rawMessage = new Uint8Array(100);

for await (
const value of ReadableStream.from([rawMessage])
.pipeThrough(new CborByteEncoderStream())
.pipeThrough(new CborSequenceDecoderStream())
) {
assert(value instanceof Uint8Array || value instanceof CborByteDecodedStream);
if (value instanceof CborByteDecodedStream) {
assertEquals(concat(await Array.fromAsync(value)), new Uint8Array(100));
} else assertEquals(value, new Uint8Array(100));
}
Hierarchy
  • ReadableStream<Uint8Array>
    • CborByteDecodedStream

Constructors

Properties

Methods

Constructors

Properties

locked: boolean

Methods

  • Parameters

    • Optionalreason: any

    Returns Promise<void>

  • Parameters

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

    Returns ReadableStreamBYOBReader

  • Returns ReadableStreamDefaultReader<Uint8Array>

  • Parameters

    • Optionaloptions: ReadableStreamGetReaderOptions

    Returns ReadableStreamReader<Uint8Array>

  • Type Parameters

    • T

    Parameters

    • transform: ReadableWritablePair<T, Uint8Array>
    • Optionaloptions: StreamPipeOptions

    Returns ReadableStream<T>

  • Parameters

    • destination: WritableStream<Uint8Array>
    • Optionaloptions: StreamPipeOptions

    Returns Promise<void>

  • Returns [ReadableStream<Uint8Array>, ReadableStream<Uint8Array>]