Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/dtils/deps.ts>streamUtils.readerFromIterable

The best unofficial library of utilities for Deno applications
Go to Latest
function streamUtils.readerFromIterable
Deprecated
Deprecated

(will be removed after 1.0.0) Convert to ReadableStream using ReadableStream.from instead.

Create a Reader from an iterable of Uint8Arrays.

import { readerFromIterable } from "https://deno.land/std@0.224.0/streams/reader_from_iterable.ts";
import { copy } from "https://deno.land/std@0.224.0/streams/copy.ts";

const file = await Deno.open("metrics.txt", { write: true });
const reader = readerFromIterable((async function* () {
while (true) {
await new Promise((r) => setTimeout(r, 1000));
const message = `data: ${JSON.stringify(Deno.metrics())}\n\n`;
yield new TextEncoder().encode(message);
}
})());
await copy(reader, file);
import { streamUtils } from "https://deno.land/x/dtils@2.5.0/deps.ts";
const { readerFromIterable } = streamUtils;

Parameters

iterable: Iterable<Uint8Array> | AsyncIterable<Uint8Array>

Returns

Reader