Skip to main content
Module

x/stream_slicing/exact_bytes_transform_stream.ts>ExactBytesTransformStream

Deno and Node.js library for working with web standard streams
Latest
class ExactBytesTransformStream
extends TransformStream<Uint8Array, Uint8Array>
import { ExactBytesTransformStream } from "https://deno.land/x/stream_slicing@v1.1.0/exact_bytes_transform_stream.ts";

A TransformStream that will only read & enqueue size amount of bytes, and will error if piped more or less than size bytes.

import { ExactBytesTransformStream } from "./exact_bytes_transform_stream.ts";
const fileUrl = new URL("./test.txt", import.meta.url);
const stat = await Deno.stat(fileUrl);
const res = await fetch(fileUrl.href);
const parts = res.body!
  .pipeThrough(new ExactBytesTransformStream(stat.size));

Constructors

new
ExactBytesTransformStream(size: number)