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

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

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

Create a Deno.Reader from an iterable of Uint8Arrays.

     import { readerFromIterable, copy } from "./conversion.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);

Parameters

iterable: Iterable<Uint8Array> | AsyncIterable<Uint8Array>

Returns

Deno.Reader