x/oak/util.ts

A middleware framework for handling HTTP with Deno 🐿️ 🦕
Very Popular
Go to Latest
function readableStreamFromReader
import { readableStreamFromReader } from "https://dotland-vbqsvsrpfncg.deno-staging.dev/x/oak@v11.1.0/util.ts?s=readableStreamFromReader";

Create a ReadableStream<Uint8Array> 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 "https://deno.land/std/io/mod.ts";

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

Parameters

reader: Deno.Reader | (Deno.Reader & Deno.Closer)[src]

Returns

ReadableStream<Uint8Array>[src]