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

x/enviromodder/setup/deps.ts>streams.readableStreamFromReader

MapLock is a module for remapper which is definitely not a nootils clone :)
Go to Latest
function streams.readableStreamFromReader
import { streams } from "https://deno.land/x/enviromodder@1.0.51/setup/deps.ts";
const { readableStreamFromReader } = streams;

Create a ReadableStream<Uint8Array> from from a Deno.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 Deno.Closer).

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

import { readableStreamFromReader } from "./mod.ts";

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

Parameters

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