import { readerFromIterable } from "https://dotland.deno.dev/std@0.119.0/streams/conversion.ts";
Create a Deno.Reader
from an iterable of Uint8Array
s.
import { readerFromIterable } 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 Deno.copy(reader, file);