Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/proc/src/deps/streams.ts>readableStreamFromReader

A high-level way to run child processes that is easy, flexible, powerful, and prevents resource leaks.
Go to Latest
function readableStreamFromReader
import { readableStreamFromReader } from "https://deno.land/x/proc@0.20.10/src/deps/streams.ts";

Create a ReadableStream<Uint8Array> from a Reader.

When the pull algorithm is called on the stream, a chunk from the reader will be read. When null is returned from the reader, the stream will be closed along with the reader (if it is also a Closer).

An example converting a Deno.FsFile into a readable stream:

import { readableStreamFromReader } from "https://deno.land/std@0.224.0/streams/readable_stream_from_reader.ts";

const file = await Deno.open("./file.txt", { read: true });
const fileStream = readableStreamFromReader(file);

Parameters

reader: Reader | (Reader & Closer)
optional
options: ReadableStreamFromReaderOptions = [UNSUPPORTED]