Class CborTextDecodedStream

A ReadableStream that wraps the decoded CBOR "Text 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 {
CborSequenceDecoderStream,
CborTextDecodedStream,
CborTextEncoderStream,
} from "@std/cbor";

const rawMessage = "a".repeat(100);

for await (
const value of ReadableStream.from([rawMessage])
.pipeThrough(new CborTextEncoderStream())
.pipeThrough(new CborSequenceDecoderStream())
) {
assert(typeof value === "string" || value instanceof CborTextDecodedStream);
if (value instanceof CborTextDecodedStream) {
assertEquals((await Array.fromAsync(value)).join(""), rawMessage);
} else assertEquals(value, rawMessage);
}
Hierarchy
  • ReadableStream<string>
    • CborTextDecodedStream

Constructors

Properties

Methods

Constructors

Properties

locked: boolean

Methods

  • Parameters

    • Optionalreason: any

    Returns Promise<void>

  • Parameters

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

    Returns ReadableStreamBYOBReader

  • Returns ReadableStreamDefaultReader<string>

  • Parameters

    • Optionaloptions: ReadableStreamGetReaderOptions

    Returns ReadableStreamReader<string>

  • Type Parameters

    • T

    Parameters

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

    Returns ReadableStream<T>

  • Parameters

    • destination: WritableStream<string>
    • Optionaloptions: StreamPipeOptions

    Returns Promise<void>

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